Skip to content

Commit b3b271c

Browse files
authored
Merge pull request #197 from RistoAle97/main
Fixed typos
2 parents f532b93 + a7fc5a2 commit b3b271c

30 files changed

+69
-69
lines changed

docs/Dataset_Preparation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The following datasets can be loaded with the current codes after downloaded (se
1717
| BAPPS | *2AFC* | SPAQ | *Mobile* |
1818
| PieAPP | *2AFC* | AVA | *Aesthetic* |
1919
| KADID-10k | | KonIQ-10k(++) | |
20-
| LIVEM | | LIVEChallange | |
20+
| LIVEM | | LIVEChallenge | |
2121
| LIVE | | [PIQ2023](https://github.com/DXOMARK-Research/PIQ2023)| Portrait dataset |
2222
| TID2013 | | [GFIQA](http://database.mmsp-kn.de/gfiqa-20k-database.html)| Face IQA Dataset |
2323
| TID2008 | | | |

pyiqa/archs/brisque_arch.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pyiqa.utils.color_util import to_y_channel
1717
from pyiqa.matlab_utils import imresize
1818
from pyiqa.matlab_utils.nss_feature import compute_nss_features
19-
from .func_util import estimate_ggd_param, estimate_aggd_param, normalize_img_with_guass
19+
from .func_util import estimate_ggd_param, estimate_aggd_param, normalize_img_with_gauss
2020
from pyiqa.utils.download_util import load_file_from_url
2121
from pyiqa.utils.registry import ARCH_REGISTRY
2222

@@ -65,7 +65,7 @@ def brisque(x: torch.Tensor,
6565
num_of_scales = 2
6666
for _ in range(num_of_scales):
6767
if version == 'matlab':
68-
xnorm = normalize_img_with_guass(x, kernel_size, kernel_sigma, padding='replicate')
68+
xnorm = normalize_img_with_gauss(x, kernel_size, kernel_sigma, padding='replicate')
6969
features.append(compute_nss_features(xnorm))
7070
elif version == 'original':
7171
features.append(natural_scene_statistics(x, kernel_size, kernel_sigma))
@@ -88,7 +88,7 @@ def brisque(x: torch.Tensor,
8888

8989
def natural_scene_statistics(luma: torch.Tensor, kernel_size: int = 7, sigma: float = 7. / 6) -> torch.Tensor:
9090

91-
luma_nrmlzd = normalize_img_with_guass(luma, kernel_size, sigma, padding='same')
91+
luma_nrmlzd = normalize_img_with_gauss(luma, kernel_size, sigma, padding='same')
9292
alpha, sigma = estimate_ggd_param(luma_nrmlzd)
9393
features = [alpha, sigma.pow(2)]
9494

pyiqa/archs/ckdn_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Learning conditional knowledge distillation for degraded-reference image quality assessment." In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 10242-10251. 2021.
55
66
Ref url: https://github.com/researchmm/CKDN.
7-
Re-implmented by: Chaofeng Chen (https://github.com/chaofengc)
7+
Re-implemented by: Chaofeng Chen (https://github.com/chaofengc)
88
99
"""
1010

pyiqa/archs/clipiqa_arch.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
AAAI 2023.
66
77
Ref url: https://github.com/IceClear/CLIP-IQA
8-
Re-implmented by: Chaofeng Chen (https://github.com/chaofengc) with the following modification:
8+
Re-implemented by: Chaofeng Chen (https://github.com/chaofengc) with the following modification:
99
- We assemble multiple prompts to improve the results of clipiqa model.
1010
1111
"""
@@ -60,7 +60,7 @@ def __init__(self, clip_model, n_ctx=16) -> None:
6060
self.register_buffer("token_prefix", init_embedding[:, :1, :]) # SOS
6161
self.register_buffer("token_suffix", init_embedding[:, 1 + n_ctx:, :]) # CLS, EOS
6262

63-
def get_prompts_with_middel_class(self,):
63+
def get_prompts_with_middle_class(self,):
6464

6565
ctx = self.ctx.to(self.token_prefix)
6666
if ctx.dim() == 2:
@@ -90,8 +90,8 @@ def get_prompts_with_middel_class(self,):
9090
return prompts
9191

9292
def forward(self, clip_model):
93-
prompts = self.get_prompts_with_middel_class()
94-
# self.get_prompts_with_middel_class
93+
prompts = self.get_prompts_with_middle_class()
94+
# self.get_prompts_with_middle_class
9595
x = prompts + clip_model.positional_embedding.type(clip_model.dtype)
9696
x = x.permute(1, 0, 2) # NLD -> LND
9797
x = clip_model.transformer(x)

pyiqa/archs/clipscore_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
1111
Reference url: https://github.com/jmhessel/clipscore
12-
Re-implmented by: Chaofeng Chen (https://github.com/chaofengc)
12+
Re-implemented by: Chaofeng Chen (https://github.com/chaofengc)
1313
"""
1414
import torch
1515
import torch.nn as nn

pyiqa/archs/cnniqa_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CNNIQA(nn.Module):
2828
r"""CNNIQA model.
2929
Args:
3030
- ker_size (int): Kernel size.
31-
- n_kers (int): Number of kernals.
31+
- n_kers (int): Number of kernels.
3232
- n1_nodes (int): Number of n1 nodes.
3333
- n2_nodes (int): Number of n2 nodes.
3434
- pretrained_model_path (String): Pretrained model path.

pyiqa/archs/dists_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class DISTS(torch.nn.Module):
5555
'''
5656

5757
def __init__(self, pretrained=True, pretrained_model_path=None, **kwargs):
58-
"""Refer to offical code https://github.com/dingkeyan93/DISTS
58+
"""Refer to official code https://github.com/dingkeyan93/DISTS
5959
"""
6060
super(DISTS, self).__init__()
6161
vgg_pretrained_features = models.vgg16(weights='IMAGENET1K_V1').features

pyiqa/archs/fid_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def forward(self,
316316

317317
# compute fid of a folder
318318
elif fdir1 is not None and fdir2 is None:
319-
assert dataset_name is not None, "When fdir2 is not provided, the reference dataset_name should be specified to calcualte fid score."
319+
assert dataset_name is not None, "When fdir2 is not provided, the reference dataset_name should be specified to calculate fid score."
320320
if verbose:
321321
print(f"compute FID of a folder with {dataset_name}-{mode}-{dataset_split}-{dataset_res} statistics")
322322
fbname1 = os.path.basename(fdir1)

pyiqa/archs/fsim_arch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def fsim(x: torch.Tensor,
5858
threshold point, below which phase congruency values get penalized.
5959
6060
Returns:
61-
- Index of similarity betwen two images. Usually in [0, 1] interval.
61+
- Index of similarity between two images. Usually in [0, 1] interval.
6262
Can be bigger than 1 for predicted :math:`x` images with higher contrast than the original ones.
6363
References:
6464
L. Zhang, L. Zhang, X. Mou and D. Zhang, "FSIM: A Feature Similarity Index for Image Quality Assessment,"
@@ -369,7 +369,7 @@ def _lowpassfilter(size: Tuple[int, int], cutoff: float, n: int) -> torch.Tensor
369369
r"""
370370
Constructs a low-pass Butterworth filter.
371371
Args:
372-
size: Tuple with heigth and width of filter to construct
372+
size: Tuple with height and width of filter to construct
373373
cutoff: Cutoff frequency of the filter in (0, 0.5()
374374
n: Filter order. Higher `n` means sharper transition.
375375
Note that `n` is doubled so that it is always an even integer.

pyiqa/archs/func_util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def diff_round(x: torch.Tensor) -> torch.Tensor:
8383
return x - x.detach() + x.round()
8484

8585

86-
def normalize_img_with_guass(
86+
def normalize_img_with_gauss(
8787
img: torch.Tensor,
8888
kernel_size: int = 7,
8989
sigma: float = 7.0 / 6,
@@ -128,7 +128,7 @@ def similarity_map(
128128
map_x: Tensor with map to be compared
129129
map_y: Tensor with map to be compared
130130
constant: Used for numerical stability
131-
alpha: Masking coefficient. Substracts - `alpha` * map_x * map_y from denominator and nominator
131+
alpha: Masking coefficient. Subtracts - `alpha` * map_x * map_y from denominator and nominator
132132
"""
133133
return (2.0 * map_x * map_y - alpha * map_x * map_y + constant) / (
134134
map_x**2 + map_y**2 - alpha * map_x * map_y + constant + EPS

pyiqa/archs/inception.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InceptionV3(nn.Module):
2424
# Maps feature dimensionality to their output blocks indices
2525
BLOCK_INDEX_BY_DIM = {
2626
64: 0, # First max pooling features
27-
192: 1, # Second max pooling featurs
27+
192: 1, # Second max pooling features
2828
768: 2, # Pre-aux classifier features
2929
2048: 3 # Final average pooling features
3030
}
@@ -176,7 +176,7 @@ def forward(self, inp, resize_input=False, normalize_input=False):
176176

177177
def _inception_v3(*args, **kwargs):
178178
"""Wraps `torchvision.models.inception_v3`
179-
Skips default weight inititialization if supported by torchvision version.
179+
Skips default weight initialization if supported by torchvision version.
180180
See https://github.com/mseitzer/pytorch-fid/issues/28.
181181
"""
182182
try:

pyiqa/archs/iqt_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
1111
Ref url: https://github.com/anse3832/IQT
12-
Re-implmented by: Chaofeng Chen (https://github.com/chaofengc)
12+
Re-implemented by: Chaofeng Chen (https://github.com/chaofengc)
1313
1414
"""
1515

pyiqa/archs/lpips_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def forward(self, in1, in0, retPerLayer=False, normalize=True):
139139
Args:
140140
in1: An input tensor. Shape :math:`(N, C, H, W)`.
141141
in0: A reference tensor. Shape :math:`(N, C, H, W)`.
142-
retPerLayer (Boolean): return result contains ressult of
142+
retPerLayer (Boolean): return result contains result of
143143
each layer or not. Default: False.
144144
normalize (Boolean): Whether to normalize image data range
145145
in [0,1] to [-1,1]. Default: True.

pyiqa/archs/mad_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Modified by: Jiadi Mo (https://github.com/JiadiMo)
66
77
Note:
8-
Offical matlab code is not available;
8+
Official matlab code is not available;
99
Pytorch version >= 1.8.0;
1010
"""
1111

pyiqa/archs/maniqa_swin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class SwinBlock(nn.Module):
162162
163163
Args:
164164
dim (int): Number of input channels.
165-
input_resolution (tuple[int]): Input resulotion.
165+
input_resolution (tuple[int]): Input resolution.
166166
num_heads (int): Number of attention heads.
167167
window_size (int): Window size.
168168
shift_size (int): Shift size for SW-MSA.

pyiqa/archs/niqe_arch.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pyiqa.utils.color_util import to_y_channel
2222
from pyiqa.utils.download_util import load_file_from_url
2323
from pyiqa.matlab_utils import imresize, fspecial, conv2d, imfilter, fitweibull, nancov, nanmean, blockproc
24-
from .func_util import estimate_aggd_param, normalize_img_with_guass, diff_round
24+
from .func_util import estimate_aggd_param, normalize_img_with_gauss, diff_round
2525
from pyiqa.archs.fsim_arch import _construct_filters
2626
from pyiqa.utils.registry import ARCH_REGISTRY
2727

@@ -119,7 +119,7 @@ def niqe(img: torch.Tensor,
119119

120120
distparam = [] # dist param is actually the multiscale features
121121
for scale in (1, 2): # perform on two scales (1, 2)
122-
img_normalized = normalize_img_with_guass(img, padding='replicate')
122+
img_normalized = normalize_img_with_gauss(img, padding='replicate')
123123

124124
distparam.append(blockproc(img_normalized, [block_size_h // scale, block_size_w // scale], fun=compute_feature))
125125

@@ -261,7 +261,7 @@ def ilniqe(img: torch.Tensor,
261261

262262
distparam = [] # dist param is actually the multiscale features
263263
for scale in (1, 2): # perform on two scales (1, 2)
264-
struct_dis = normalize_img_with_guass(O_img[:, [2]], kernel_size=5, sigma=5. / 6, padding='replicate')
264+
struct_dis = normalize_img_with_gauss(O_img[:, [2]], kernel_size=5, sigma=5. / 6, padding='replicate')
265265

266266
dx, dy = gauDerivative(sigmaForGauDerivative / (scale**scaleFactorForGaussianDer), device=img)
267267

pyiqa/archs/nlpd_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def nlpd(self, x1, x2):
149149
x1: An input tensor. Shape :math:`(N, C, H, W)`.
150150
x2: A target tensor. Shape :math:`(N, C, H, W)`.
151151
Returns:
152-
Index of similarity betwen two images. Usually in [0, 1] interval.
152+
Index of similarity between two images. Usually in [0, 1] interval.
153153
"""
154154
assert (self.test_y_channel and self.channels == 1) or (
155155
not self.test_y_channel and self.channels == 3), 'Number of channel and convert to YCBCR should be match'

pyiqa/archs/nrqm_arch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
default_model_urls = {'url': 'https://github.com/chaofengc/IQA-PyTorch/releases/download/v0.1-weights/NRQM_model.mat'}
2727

2828

29-
def get_guass_pyramid(x: Tensor, scale: int = 2):
29+
def get_gauss_pyramid(x: Tensor, scale: int = 2):
3030
r"""Get gaussian pyramid images with gaussian kernel.
3131
"""
3232
pyr = [x]
@@ -327,7 +327,7 @@ def nrqm(
327327
# crop image
328328
b, c, h, w = img.shape
329329
img = img.double()
330-
img_pyr = get_guass_pyramid(img / 255.)
330+
img_pyr = get_gauss_pyramid(img / 255.)
331331

332332
# DCT features
333333
f1 = []

pyiqa/archs/piqe_arch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from pyiqa.utils.color_util import to_y_channel
1717
from pyiqa.matlab_utils import symm_pad
18-
from pyiqa.archs.func_util import normalize_img_with_guass
18+
from pyiqa.archs.func_util import normalize_img_with_gauss
1919
from pyiqa.utils.registry import ARCH_REGISTRY
2020

2121

@@ -52,7 +52,7 @@ def piqe(
5252
new_height, new_width = img.shape[2], img.shape[3]
5353

5454
# Normalize image to zero mean and ~unit std
55-
img_normalized = normalize_img_with_guass(img, padding='replicate')
55+
img_normalized = normalize_img_with_gauss(img, padding='replicate')
5656

5757
# Create blocks
5858
blocks = img_normalized.unfold(2, block_size, block_size).unfold(3, block_size, block_size)

pyiqa/archs/psnr_arch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def psnr(x, y, test_y_channel=False, data_range=1.0, eps=1e-8, color_space='yiq'
2828
- data_range: Maximum value range of images (default 1.0).
2929
3030
Returns:
31-
PSNR Index of similarity betwen two images.
31+
PSNR Index of similarity between two images.
3232
"""
3333

3434
if (x.shape[1] == 3) and test_y_channel:
@@ -50,7 +50,7 @@ class PSNR(nn.Module):
5050
- test_y_channel (Boolean): Convert RGB image to YCbCr format and computes PSNR
5151
only on luminance channel if `True`. Compute on all 3 channels otherwise.
5252
- kwargs: other parameters, including
53-
- data_range: maximun numeric value
53+
- data_range: maximum numeric value
5454
- eps: small constant for numeric stability
5555
Return:
5656
score (torch.Tensor): (B, 1)

pyiqa/archs/ssim_arch.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
Modified by: Jiadi Mo (https://github.com/JiadiMo)
99
1010
Refer to:
11-
- Offical SSIM matlab code from https://www.cns.nyu.edu/~lcv/ssim/;
11+
- Official SSIM matlab code from https://www.cns.nyu.edu/~lcv/ssim/;
1212
- PIQ from https://github.com/photosynthesis-team/piq;
1313
- BasicSR from https://github.com/xinntao/BasicSR/blob/master/basicsr/metrics/psnr_ssim.py;
14-
- Offical MS-SSIM matlab code from https://ece.uwaterloo.ca/~z70wang/research/iwssim/msssim.zip;
15-
- Offical CW-SSIM matlab code from
14+
- Official MS-SSIM matlab code from https://ece.uwaterloo.ca/~z70wang/research/iwssim/msssim.zip;
15+
- Official CW-SSIM matlab code from
1616
https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/43017/versions/1/download/zip;
1717
1818
"""
@@ -118,7 +118,7 @@ def ms_ssim(X, Y, win=None, data_range=1., downsample=False, test_y_channel=True
118118
test_y_channel: Boolean, whether to use y channel on ycbcr.
119119
is_prod: Boolean, calculate product or sum between mcs and weight.
120120
Returns:
121-
Index of similarity betwen two images. Usually in [0, 1] interval.
121+
Index of similarity between two images. Usually in [0, 1] interval.
122122
"""
123123
if not X.shape == Y.shape:
124124
raise ValueError('Input images must have the same dimensions.')
@@ -248,7 +248,7 @@ def cw_ssim(self, x, y, test_y_channel):
248248
y: A target tensor. Shape :math:`(N, C, H, W)`.
249249
test_y_channel: Boolean, whether to use y channel on ycbcr.
250250
Returns:
251-
Index of similarity betwen two images. Usually in [0, 1] interval.
251+
Index of similarity between two images. Usually in [0, 1] interval.
252252
"""
253253
# Whether calculate on y channel of ycbcr
254254
if test_y_channel and x.shape[1] == 3:

pyiqa/archs/stlpips_arch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def forward(self, in0, in1, retPerLayer=False, normalize=True):
123123
Args:
124124
in1: An input tensor. Shape :math:`(N, C, H, W)`.
125125
in0: A reference tensor. Shape :math:`(N, C, H, W)`.
126-
retPerLayer (Boolean): return result contains ressult of
126+
retPerLayer (Boolean): return result contains result of
127127
each layer or not. Default: False.
128128
normalize (Boolean): Whether to normalize image data range
129129
in [0,1] to [-1,1]. Default: True.

pyiqa/archs/topiq_swin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class SwinTransformerBlock(nn.Module):
270270
271271
Args:
272272
dim (int): Number of input channels.
273-
input_resolution (tuple[int]): Input resulotion.
273+
input_resolution (tuple[int]): Input resolution.
274274
window_size (int): Window size.
275275
num_heads (int): Number of attention heads.
276276
head_dim (int): Enforce the number of channels per head

0 commit comments

Comments
 (0)