pyiqa.archs.nrqm_arch ===================== .. py:module:: pyiqa.archs.nrqm_arch .. autoapi-nested-parse:: 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 --------------- .. py:data:: default_model_urls .. py:function:: get_gauss_pyramid(x: torch.Tensor, scale: int = 2) Get gaussian pyramid images with gaussian kernel. .. py:function:: get_var_gen_gauss(x, eps=1e-07) Get mean and variance of input local patch. .. py:function:: gamma_gen_gauss(x: torch.Tensor, block_seg=10000.0) General gaussian distribution estimation. :param block_seg: maximum number of blocks in parallel to avoid OOM .. py:function:: gamma_dct(dct_img_block: torch.Tensor) Generalized gaussian distribution features .. py:function:: coeff_var_dct(dct_img_block: torch.Tensor) Gaussian var, mean features .. py:function:: oriented_dct_rho(dct_img_block: torch.Tensor) Oriented frequency features .. py:function:: block_dct(img: torch.Tensor) Get local frequency features .. py:function:: norm_sender_normalized(pyr, num_scale=2, num_bands=6, blksz=3, eps=1e-12) Normalize pyramid with local spatial neighbor and band neighbor .. py:function:: global_gsm(img: torch.Tensor) Global feature from gassian scale mixture model .. py:function:: tree_regression(feat, ldau, rdau, threshold_value, pred_value, best_attri) Simple decision tree regression. .. py:function:: random_forest_regression(feat, ldau, rdau, threshold_value, pred_value, best_attri) Simple random forest regression. Note: currently, this is non-differentiable and only support CPU. .. py:function:: nrqm(img: torch.Tensor, linear_param, rf_param) -> torch.Tensor 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 .. py:function:: 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 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. :type crop_border: int :param test_y_channel: Whether converted to 'y' (of MATLAB YCbCr) or 'gray'. :type test_y_channel: Bool :param pretrained_model_path: The pretrained model path. :type pretrained_model_path: String :returns: NIQE result. :rtype: Tensor .. py:class:: NRQM(test_y_channel: bool = True, color_space: str = 'yiq', crop_border: int = 0, pretrained_model_path: str = None) Bases: :py:obj:`torch.nn.Module` NRQM 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. :param - channels: Number of processed channel. :type - channels: int :param - test_y_channel: whether to use y channel on ycbcr. :type - test_y_channel: Boolean :param - crop_border: Cropped pixels in each edge of an image. These pixels are not involved in the metric calculation. :type - crop_border: int :param - pretrained_model_path: The pretrained model path. :type - pretrained_model_path: String .. py:method:: forward(X: torch.Tensor) -> torch.Tensor Computation of NRQM metric. :param X: An input tensor. Shape :math:`(N, C, H, W)`. :returns: Value of nrqm metric. .. py:class:: PI(crop_border=4, color_space='ycbcr') Bases: :py:obj:`torch.nn.Module` Perceptual 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) :param - color_space: color space of y channel, default ycbcr. :type - color_space: str :param - crop_border: Cropped pixels in each edge of an image, default 4. :type - crop_border: int .. py:method:: forward(X: torch.Tensor) -> torch.Tensor Computation of PI metric. :param X: An input tensor. Shape :math:`(N, C, H, W)`. :returns: Value of PI metric.