Skip to content

Commit b2b5ad1

Browse files
committed
Clean some codes.
1 parent 6377322 commit b2b5ad1

12 files changed

Lines changed: 23 additions & 844 deletions

File tree

pyiqa/archs/arch_util.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import collections.abc
21
import math
2+
33
import torch
4-
import torchvision
5-
import warnings
6-
from distutils.version import LooseVersion
7-
from itertools import repeat
84
from torch import nn as nn
95
from torch.nn import functional as F
106
from torch.nn import init as init
117
from torch.nn.modules.batchnorm import _BatchNorm
128

13-
from pyiqa.utils import get_root_logger
149
from pyiqa.utils.download_util import load_file_from_url
1510

1611
# --------------------------------------------

pyiqa/archs/brisque_arch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import torch
1717
import torch.nn.functional as F
1818
from pyiqa.utils.color_util import to_y_channel
19-
from pyiqa.utils.matlab_functions import fspecial_gauss, imresize
20-
from .func_util import estimate_ggd_param, estimate_aggd_param, safe_sqrt, normalize_img_with_guass
19+
from pyiqa.utils.matlab_functions import imresize
20+
from .func_util import estimate_ggd_param, estimate_aggd_param, normalize_img_with_guass
2121
from pyiqa.utils.download_util import load_file_from_url
2222
from pyiqa.utils.registry import ARCH_REGISTRY
2323

pyiqa/archs/ckdn_arch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import torchvision as tv
1515
from pyiqa.utils.registry import ARCH_REGISTRY
1616
from pyiqa.archs.arch_util import load_pretrained_network
17-
from pyiqa.utils.download_util import load_file_from_url
1817

1918
try:
2019
from torch.hub import load_state_dict_from_url

pyiqa/archs/dbcnn_arch.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
77
"""
88

9-
import os
10-
119
import torch
1210
import torchvision
1311
import torch.nn as nn

pyiqa/archs/func_util.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99

1010
def torch_cov(tensor, rowvar=True, bias=False):
11-
"""Estimate a covariance matrix (np.cov)
12-
https://gist.github.com/ModarTensai/5ab449acba9df1a26c12060240773110
11+
r"""Estimate a covariance matrix (np.cov)
12+
Ref: https://gist.github.com/ModarTensai/5ab449acba9df1a26c12060240773110
1313
"""
1414
tensor = tensor if rowvar else tensor.transpose(-1, -2)
1515
tensor = tensor - tensor.mean(dim=-1, keepdim=True)
@@ -18,6 +18,11 @@ def torch_cov(tensor, rowvar=True, bias=False):
1818

1919

2020
def safe_sqrt(x: torch.Tensor) -> torch.Tensor:
21+
r"""Safe sqrt with EPS to ensure numeric stability.
22+
23+
Args:
24+
x (torch.Tensor): should be non-negative
25+
"""
2126
EPS = torch.finfo(x.dtype).eps
2227
return torch.sqrt(x + EPS)
2328

pyiqa/archs/inception.py

Lines changed: 0 additions & 307 deletions
This file was deleted.

pyiqa/archs/nima_arch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
r"""NIMA model.
2+
Reference:
3+
Talebi, Hossein, and Peyman Milanfar. "NIMA: Neural image assessment."
4+
IEEE transactions on image processing 27, no. 8 (2018): 3998-4011.
25
36
Created by: https://github.com/yunxiaoshi/Neural-IMage-Assessment/blob/master/model/model.py
47
@@ -28,9 +31,6 @@ class NIMA(nn.Module):
2831
default input shape:
2932
- vgg and mobilenet: (N, 3, 224, 224)
3033
- inception: (N, 3, 299, 299)
31-
Reference:
32-
Talebi, Hossein, and Peyman Milanfar. "NIMA: Neural image assessment."
33-
IEEE transactions on image processing 27, no. 8 (2018): 3998-4011.
3434
"""
3535
def __init__(self,
3636
base_model_name='vgg16',

0 commit comments

Comments
 (0)