torchimage.metrics package¶
Subpackages¶
Submodules¶
torchimage.metrics.mse module¶
torchimage.metrics.psnr module¶
- class torchimage.metrics.psnr.PSNR(max_value=1, eps=0.0, *, reduction='mean')¶
Bases:
torchimage.metrics.mse.MSE
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, reduce_axes=None)¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
torchimage.metrics.ssim module¶
- class torchimage.metrics.ssim.MS_SSIM(weights=None, use_prod=True, blur: torchimage.pooling.base.BasePoolNd = 'gaussian', padder=None, K1=0.01, K2=0.03, eps=1e-08, use_sample_covariance=True, crop_border=True)¶
Bases:
torchimage.metrics.ssim.SSIM
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, content_axes=slice(2, None, None), reduce_axes=slice(1, None, None), full=False)¶
- Parameters
y_pred (torch.Tensor) – The first input tensor. Order doesn’t matter because SSIM is symmetric with respect to input images.
y_true (torch.Tensor) – The second input tensor.
content_axes (None, int, slice, tuple) – Axes that describe the “content” of an image. This includes depth, height, and width but excludes batch or channel dimensions.
reduce_axes (None, int, slice, tuple) –
The final SSIM score will average the full SSIM map across these axes.
If reduce_axes is None (all axes are reduce axes), the output score will be a scalar (useful as a loss function). If reduce_axes doesn’t include batch axes, then it returns a 1d tensor of SSIM scores for every data point.
full (bool) – Whether to return the full SSIM map as well. Default: False.
- Returns
score (torch.Tensor) – The SSIM score tensor where content axes are reduced.
full_tensor (torch.Tensor) – The full output SSIM with the same shape as input images. This argument is only returned when
full=True
.
- property n_levels¶
- training: bool¶
- class torchimage.metrics.ssim.SSIM(blur: torchimage.pooling.base.BasePoolNd = 'gaussian', padder=None, K1=0.01, K2=0.03, use_sample_covariance=True, crop_border=True)¶
Bases:
torch.nn.modules.module.Module
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, content_axes=slice(2, None, None), reduce_axes=slice(1, None, None), *, full=False)¶
- Parameters
y_pred (torch.Tensor) – The first input tensor. Order doesn’t matter because SSIM is symmetric with respect to input images.
y_true (torch.Tensor) – The second input tensor.
content_axes (None, int, slice, tuple) – Axes that describe the “content” of an image. This includes depth, height, and width but excludes batch or channel dimensions.
reduce_axes (None, int, slice, tuple) –
The final SSIM score will average the full SSIM map across these axes.
If reduce_axes is None (all axes are reduce axes), the output score will be a scalar (useful as a loss function). If reduce_axes doesn’t include batch axes, then it returns a 1d tensor of SSIM scores for every data point.
full (bool) – Whether to return the full SSIM map as well. Default: False.
- Returns
score (torch.Tensor) – The SSIM score tensor where content axes are reduced.
full_tensor (torch.Tensor) – The full output SSIM with the same shape as input images. This argument is only returned when
full=True
.
- training: bool¶
Module contents¶
- class torchimage.metrics.MSE(*, reduction='mean')¶
Bases:
torchimage.metrics.base.BaseMetric
- forward_full(y_pred: torch.Tensor, y_true: torch.Tensor)¶
- training: bool¶
- class torchimage.metrics.MS_SSIM(weights=None, use_prod=True, blur: torchimage.pooling.base.BasePoolNd = 'gaussian', padder=None, K1=0.01, K2=0.03, eps=1e-08, use_sample_covariance=True, crop_border=True)¶
Bases:
torchimage.metrics.ssim.SSIM
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, content_axes=slice(2, None, None), reduce_axes=slice(1, None, None), full=False)¶
- Parameters
y_pred (torch.Tensor) – The first input tensor. Order doesn’t matter because SSIM is symmetric with respect to input images.
y_true (torch.Tensor) – The second input tensor.
content_axes (None, int, slice, tuple) – Axes that describe the “content” of an image. This includes depth, height, and width but excludes batch or channel dimensions.
reduce_axes (None, int, slice, tuple) –
The final SSIM score will average the full SSIM map across these axes.
If reduce_axes is None (all axes are reduce axes), the output score will be a scalar (useful as a loss function). If reduce_axes doesn’t include batch axes, then it returns a 1d tensor of SSIM scores for every data point.
full (bool) – Whether to return the full SSIM map as well. Default: False.
- Returns
score (torch.Tensor) – The SSIM score tensor where content axes are reduced.
full_tensor (torch.Tensor) – The full output SSIM with the same shape as input images. This argument is only returned when
full=True
.
- property n_levels¶
- training: bool¶
- class torchimage.metrics.PSNR(max_value=1, eps=0.0, *, reduction='mean')¶
Bases:
torchimage.metrics.mse.MSE
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, reduce_axes=None)¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool¶
- class torchimage.metrics.SSIM(blur: torchimage.pooling.base.BasePoolNd = 'gaussian', padder=None, K1=0.01, K2=0.03, use_sample_covariance=True, crop_border=True)¶
Bases:
torch.nn.modules.module.Module
- forward(y_pred: torch.Tensor, y_true: torch.Tensor, content_axes=slice(2, None, None), reduce_axes=slice(1, None, None), *, full=False)¶
- Parameters
y_pred (torch.Tensor) – The first input tensor. Order doesn’t matter because SSIM is symmetric with respect to input images.
y_true (torch.Tensor) – The second input tensor.
content_axes (None, int, slice, tuple) – Axes that describe the “content” of an image. This includes depth, height, and width but excludes batch or channel dimensions.
reduce_axes (None, int, slice, tuple) –
The final SSIM score will average the full SSIM map across these axes.
If reduce_axes is None (all axes are reduce axes), the output score will be a scalar (useful as a loss function). If reduce_axes doesn’t include batch axes, then it returns a 1d tensor of SSIM scores for every data point.
full (bool) – Whether to return the full SSIM map as well. Default: False.
- Returns
score (torch.Tensor) – The SSIM score tensor where content axes are reduced.
full_tensor (torch.Tensor) – The full output SSIM with the same shape as input images. This argument is only returned when
full=True
.
- training: bool¶