Utilities#
Resize and interpolate the image to the given shape. |
resize_img#
- saliency_metrics.utils.resize_img(img, output_shape, **kwargs)[source]#
Resize and interpolate the image to the given shape.
This function simply calls
torch.nn.functional.interpolateifimgis atorch.Tensor, orcv2.resizeifimgis anumpy.ndarray.Note
If
imgis anumpy.ndarray, then its data type must benumpy.uint8.- Parameters
img (
TypeVar(T,Tensor,ndarray)) – Input image. Can betorch.Tensorwith shape(num_samples, num_channels, height, width)ornumpy.ndarraywith shape(height, width, 3)or(height, width).output_shape (
Tuple[int,int]) – output shape in the format of(out_height, out_width).**kwargs – other interpolation arguments. See also interpolate or resize.
- Return type
- Returns
The interpolated image.