BlurStrength#
- class deepinv.loss.metric.BlurStrength(h_size=11, **kwargs)[source]#
Bases:
MetricNo-reference blur strength metric for batched images.
Returns a value in (0, 1) for each image in the batch, where 0 indicates a very sharp image and 1 indicates a very blurry image.
The metric has been introduced in Crete et al. [26].
- Parameters:
h_size (int) β size of the uniform blur filter. Default: 11.
complex_abs (bool) β perform complex magnitude before passing data to metric function. If
True, the data must either be of complex dtype or have size 2 in the channel dimension (usually the second dimension after batch).reduction (str) β a method to reduce metric score over individual batch scores.
mean: takes the mean,sumtakes the sum,noneor None no reduction will be applied (default).norm_inputs (str) β normalize images before passing to metric.
l2normalizes by \({\ell}_2\) spatial norm,min_maxnormalizes by min and max of each input.check_input_range (bool) β if True,
pyiqawill raise error if inputs arenβt in the appropriate range[0, 1].center_crop (int, tuple[int], None) β If not
None(default), center crop the tensor(s) before computing the metrics. If anintis provided, the cropping is applied equally on all spatial dimensions (by default, all dimensions except the first two). Iftupleofint, cropping is performed over the lastlen(center_crop)dimensions. If positive values are provided, a standard center crop is applied. If negative (or zero) values are passed, cropping will be done by removingcenter_croppixels from the borders (useful when tensors vary in size across the dataset).
- Example:
>>> from deepinv.loss.metric import BlurStrength >>> m = BlurStrength() >>> x_net = torch.randn(2, 3, 16, 16) # batch of 2 RGB images >>> m(x_net).shape torch.Size([2])
- static sobel1d(x, axis)[source]#
Batched 1D Sobel derivative along an arbitrary axis.
- Parameters:
x (torch.Tensor) β
(B, C, ...)axis (int) β axis along which to compute sobel derivative along.
- Returns:
torch.Tensorof shape(B, C, ...)- Return type:
- static uniform_filter1d(x, size, axis)[source]#
Batched 1D uniform filter along an arbitrary axis.
- Parameters:
x (torch.Tensor) β input tensor of shape
(B, C, ...)size (int) β size of filter
axis (int) β axis along which to compute filter
- Returns:
filtered tensor of shape
(B, C, ...)- Return type: