pyiqa.archs.brisque_arch ======================== .. py:module:: pyiqa.archs.brisque_arch .. autoapi-nested-parse:: BRISQUE Metric Created by: https://github.com/photosynthesis-team/piq/blob/master/piq/brisque.py Modified by: Jiadi Mo (https://github.com/JiadiMo) Reference: MATLAB codes: https://live.ece.utexas.edu/research/Quality/index_algorithms.htm BRISQUE; Pretrained model from: https://github.com/photosynthesis-team/piq/releases/download/v0.4.0/brisque_svm_weights.pt Module Contents --------------- .. py:data:: default_model_urls .. py:function:: brisque(x: torch.Tensor, kernel_size: int = 7, kernel_sigma: float = 7 / 6, test_y_channel: bool = True, sv_coef: torch.Tensor = None, sv: torch.Tensor = None, gamma: float = 0.05, rho: float = -153.591, scale: float = 1, version: str = 'original') -> torch.Tensor Interface of BRISQUE index. :param x: An input tensor. Shape :math:`(N, C, H, W)`. :type x: torch.Tensor :param kernel_size: The side-length of the sliding window used in comparison. Must be an odd value. :type kernel_size: int :param kernel_sigma: Sigma of normal distribution. :type kernel_sigma: float :param test_y_channel: Whether to use the y-channel of YCBCR. :type test_y_channel: bool :param sv_coef: Support vector coefficients. :type sv_coef: torch.Tensor :param sv: Support vectors. :type sv: torch.Tensor :param gamma: Gamma parameter for the RBF kernel. :type gamma: float :param rho: Bias term in the decision function. :type rho: float :param scale: Scaling factor for the features. :type scale: float :param version: Version of the BRISQUE implementation ('original' or 'matlab'). :type version: str :returns: Value of BRISQUE index. :rtype: torch.Tensor .. rubric:: References Mittal, Anish, Anush Krishna Moorthy, and Alan Conrad Bovik. "No-reference image quality assessment in the spatial domain." IEEE Transactions on image processing 21, no. 12 (2012): 4695-4708. .. py:function:: natural_scene_statistics(luma: torch.Tensor, kernel_size: int = 7, sigma: float = 7.0 / 6) -> torch.Tensor Compute natural scene statistics (NSS) features for a given luminance image. :param luma: Luminance image tensor. :type luma: torch.Tensor :param kernel_size: Size of the Gaussian kernel. :type kernel_size: int :param sigma: Standard deviation of the Gaussian kernel. :type sigma: float :returns: NSS features. :rtype: torch.Tensor .. py:function:: scale_features(features: torch.Tensor) -> torch.Tensor Scale features to the range [-1, 1] based on predefined feature ranges. :param features: Input features. :type features: torch.Tensor :returns: Scaled features. :rtype: torch.Tensor .. py:function:: rbf_kernel(features: torch.Tensor, sv: torch.Tensor, gamma: float = 0.05) -> torch.Tensor Compute the Radial Basis Function (RBF) kernel between features and support vectors. :param features: Input features. :type features: torch.Tensor :param sv: Support vectors. :type sv: torch.Tensor :param gamma: Gamma parameter for the RBF kernel. :type gamma: float :returns: RBF kernel values. :rtype: torch.Tensor .. py:class:: BRISQUE(kernel_size: int = 7, kernel_sigma: float = 7 / 6, test_y_channel: bool = True, version: str = 'original', pretrained_model_path: str = None) Bases: :py:obj:`torch.nn.Module` Creates a criterion that measures the BRISQUE score. :param kernel_size: By default, the mean and covariance of a pixel is obtained by convolution with given filter_size. Must be an odd value. :type kernel_size: int :param kernel_sigma: Standard deviation for Gaussian kernel. :type kernel_sigma: float :param test_y_channel: Whether to use the y-channel of YCBCR. :type test_y_channel: bool :param version: Version of the BRISQUE implementation ('original' or 'matlab'). :type version: str :param pretrained_model_path: The model path. :type pretrained_model_path: str, optional .. attribute:: kernel_size The side-length of the sliding window used in comparison. :type: int .. attribute:: kernel_sigma Sigma of normal distribution. :type: float .. attribute:: test_y_channel Whether to use the y-channel of YCBCR. :type: bool .. attribute:: sv_coef Support vector coefficients. :type: torch.Tensor .. attribute:: sv Support vectors. :type: torch.Tensor .. attribute:: gamma Gamma parameter for the RBF kernel. :type: float .. attribute:: rho Bias term in the decision function. :type: float .. attribute:: scale Scaling factor for the features. :type: float .. attribute:: version Version of the BRISQUE implementation ('original' or 'matlab'). :type: str .. py:method:: forward(x: torch.Tensor) -> torch.Tensor Computation of BRISQUE score as a loss function. :param x: An input tensor with (N, C, H, W) shape. RGB channel order for colour images. :type x: torch.Tensor :returns: Value of BRISQUE metric. :rtype: torch.Tensor