pyiqa.archs.nrqm_arch¶
NRQM Metric, proposed in
Chao Ma, Chih-Yuan Yang, Xiaokang Yang, Ming-Hsuan Yang “Learning a No-Reference Quality Metric for Single-Image Super-Resolution” Computer Vision and Image Understanding (CVIU), 2017
Matlab reference: https://github.com/chaoma99/sr-metric This PyTorch implementation by: Chaofeng Chen (https://github.com/chaofengc)
Module Contents¶
- pyiqa.archs.nrqm_arch.get_gauss_pyramid(x: torch.Tensor, scale: int = 2)[source]¶
Get gaussian pyramid images with gaussian kernel.
- pyiqa.archs.nrqm_arch.get_var_gen_gauss(x, eps=1e-07)[source]¶
Get mean and variance of input local patch.
- pyiqa.archs.nrqm_arch.gamma_gen_gauss(x: torch.Tensor, block_seg=10000.0)[source]¶
General gaussian distribution estimation.
- Parameters:
block_seg – maximum number of blocks in parallel to avoid OOM
- pyiqa.archs.nrqm_arch.gamma_dct(dct_img_block: torch.Tensor)[source]¶
Generalized gaussian distribution features
- pyiqa.archs.nrqm_arch.coeff_var_dct(dct_img_block: torch.Tensor)[source]¶
Gaussian var, mean features
- pyiqa.archs.nrqm_arch.oriented_dct_rho(dct_img_block: torch.Tensor)[source]¶
Oriented frequency features
- pyiqa.archs.nrqm_arch.norm_sender_normalized(pyr, num_scale=2, num_bands=6, blksz=3, eps=1e-12)[source]¶
Normalize pyramid with local spatial neighbor and band neighbor
- pyiqa.archs.nrqm_arch.global_gsm(img: torch.Tensor)[source]¶
Global feature from gassian scale mixture model
- pyiqa.archs.nrqm_arch.tree_regression(feat, ldau, rdau, threshold_value, pred_value, best_attri)[source]¶
Simple decision tree regression.
- pyiqa.archs.nrqm_arch.random_forest_regression(feat, ldau, rdau, threshold_value, pred_value, best_attri)[source]¶
Simple random forest regression.
Note: currently, this is non-differentiable and only support CPU.
- pyiqa.archs.nrqm_arch.nrqm(img: torch.Tensor, linear_param, rf_param) torch.Tensor[source]¶
Calculate NRQM :param img: Input image. :type img: Tensor :param linear_param: (4, 1) linear regression params :type linear_param: np.array :param rf_param: params of 3 random forest for 3 kinds of features
- pyiqa.archs.nrqm_arch.calculate_nrqm(img: torch.Tensor, crop_border: int = 0, test_y_channel: bool = True, color_space: str = 'yiq', linear_param: torch.Tensor = None, rf_params_list: list = None, **kwargs) torch.Tensor[source]¶
Calculate NRQM :param img: Input image whose quality needs to be computed. :type img: Tensor :param crop_border: Cropped pixels in each edge of an image. These
pixels are not involved in the metric calculation.
- Parameters:
test_y_channel (Bool) – Whether converted to ‘y’ (of MATLAB YCbCr) or ‘gray’.
pretrained_model_path (String) – The pretrained model path.
- Returns:
NIQE result.
- Return type:
Tensor
- class pyiqa.archs.nrqm_arch.NRQM(test_y_channel: bool = True, color_space: str = 'yiq', crop_border: int = 0, pretrained_model_path: str = None)[source]¶
Bases:
torch.nn.ModuleNRQM metric
Ma, Chao, Chih-Yuan Yang, Xiaokang Yang, and Ming-Hsuan Yang. “Learning a no-reference quality metric for single-image super-resolution.” Computer Vision and Image Understanding 158 (2017): 1-16.
- Parameters:
channels (-) – Number of processed channel.
test_y_channel (-) – whether to use y channel on ycbcr.
crop_border (-) – Cropped pixels in each edge of an image. These pixels are not involved in the metric calculation.
pretrained_model_path (-) – The pretrained model path.
- class pyiqa.archs.nrqm_arch.PI(crop_border=4, color_space='ycbcr')[source]¶
Bases:
torch.nn.ModulePerceptual Index (PI), introduced by
Blau, Yochai, Roey Mechrez, Radu Timofte, Tomer Michaeli, and Lihi Zelnik-Manor. “The 2018 pirm challenge on perceptual image super-resolution.” In Proceedings of the European Conference on Computer Vision (ECCV) Workshops, pp. 0-0. 2018. Ref url: https://github.com/roimehrez/PIRM2018
It is a combination of NIQE and NRQM: 1/2 * ((10 - NRQM) + NIQE)
- Parameters:
color_space (-) – color space of y channel, default ycbcr.
crop_border (-) – Cropped pixels in each edge of an image, default 4.