helios.metrics.metrics¶
Attributes¶
Global instance of the registry for metric functions. |
Classes¶
Calculate PSNR (Peak Signal-to-Noise Ratio). |
|
Calculate SSIM (structural similarity). |
|
Calculate the mAP (Mean Average Precision). |
|
Compute the MAE (Mean-Average Precision) score. |
Functions¶
|
Create the metric function for the given type. |
Module Contents¶
- helios.metrics.metrics.METRICS_REGISTRY¶
Global instance of the registry for metric functions.
Example
import helios.metrics as hlm # This automatically registers your metric function. @hlm.METRICS_REGISTRY.register class MyMetric: ... # Alternatively you can manually register a metric function like this: hlm.METRICS_REGISTRY.register(MyMetric)
- helios.metrics.metrics.create_metric(type_name: str, *args: Any, **kwargs: Any) torch.nn.Module [source]¶
Create the metric function for the given type.
- Parameters:
type_name – the type of the loss to create.
args – positional arguments to pass into the metric.
kwargs – keyword arguments to pass into the metric.
- Returns:
The metric function
- class helios.metrics.metrics.CalculatePSNR(crop_border: int, input_order: str = 'HWC', test_y_channel: bool = False)[source]¶
Bases:
torch.nn.Module
Calculate PSNR (Peak Signal-to-Noise Ratio).
Implementation follows: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio. Note that the input_order is only needed if you plan to evaluate Numpy images. It can be left as default otherwise.
- Parameters:
crop_border – Cropped pixels in each edge of an image. These pixels are not involved in the calculation.
input_order – Whether the input order is “HWC” or “CHW”. Defaults to “HWC”.
test_y_channel – Test on Y channel of YCbCr. Defaults to false.
- class helios.metrics.metrics.CalculateSSIM(crop_border: int, input_order: str = 'HWC', test_y_channel: bool = False)[source]¶
Bases:
torch.nn.Module
Calculate SSIM (structural similarity).
Implementation follows: ‘Image quality assesment: From error visibility to structural similarity’. Results are identical to those of the official MATLAB code in https://ece.uwaterloo.ca/~z70wang/research/ssim/. For three-channel images, SSIM is calculated for each channel and then averaged.
- Parameters:
crop_border – Cropped pixels in each edge of an image. These pixels are not involved in the calculation.
input_order – Whether the input order is “HWC” or “CHW”. Defaults to “HWC”.
test_y_channel – Test on Y channel of YCbCr. Defaults to false.
- class helios.metrics.metrics.CalculateMAP(*args, **kwargs)[source]¶
Bases:
torch.nn.Module
Calculate the mAP (Mean Average Precision).
Implementation follows: https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)#Mean_average_precision.
- class helios.metrics.metrics.CalculateMAE(scale: float = 1)[source]¶
Bases:
torch.nn.Module
Compute the MAE (Mean-Average Precision) score.
Implementation follows: https://en.wikipedia.org/wiki/Mean_absolute_error. The scale argument is used in the event that the input arrays are not in the range \([0, 1]\) but instead have been scaled to be in the range \([0, N]\) where \(N\) is the factor. For example, if the arrays are images in the range \([0, 255]\), then the scaling factor should be set to 255. If the arrays are already in the range \([0, 1]\), then the scale can be omitted.
- Parameters:
scale – scaling factor that was used on the input tensors. Defaults to 1.