Skip to content

Commit

Permalink
fix: 🐛 fix niqe with gray input
Browse files Browse the repository at this point in the history
  • Loading branch information
chaofengc committed Apr 27, 2023
1 parent 1947903 commit 212ecef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyiqa/archs/niqe_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ def calculate_niqe(img: torch.Tensor,
mu_pris_param = mu_pris_param.repeat(img.size(0), 1)
cov_pris_param = cov_pris_param.repeat(img.size(0), 1, 1)

if test_y_channel and img.shape[1] == 3:
# NIQE only support gray image
if img.shape[1] == 3:
img = to_y_channel(img, 255, color_space)
elif img.shape[1] == 1:
img = img * 255

img = diff_round(img)
img = img.to(torch.float64)
Expand Down Expand Up @@ -478,5 +481,6 @@ def forward(self, X: torch.Tensor) -> torch.Tensor:
Returns:
Value of niqe metric in [0, 1] range.
"""
assert X.shape[1] == 3, 'ILNIQE only support input image with 3 channels'
score = calculate_ilniqe(X, self.crop_border, self.pretrained_model_path)
return score

0 comments on commit 212ecef

Please sign in to comment.