load_image#

deepinv.utils.load_image(path, img_size=None, grayscale=False, resize_mode='crop', device='cpu', dtype=torch.float32)[source]#

Load an image from a file and return a torch.Tensor.

Parameters:
  • path (str) – Path to the image file.

  • img_size (int, tuple[int]) – Size of the image to return.

  • grayscale (bool) – Whether to convert the image to grayscale.

  • resize_mode (str) – If img_size is not None, options are "crop" or "resize".

  • device (str) – Device on which to load the image (gpu or cpu).

Returns:

torch.Tensor containing the image.