Floating point images in torchvision

Hi folks,

TorchVision noob question.

I’m doing some research using PyTorch in animation and visual effects, where the standard image format is floating point exr files (lossless, high dynaimc range). From some cursory reading, it seems that TorchVision utilises PIL, which I believe is limited to 8bit int images?

I’m using another library for handling of exr files (OpenImageIO), from which I can load a floating point image, perform some operations such as resize etc, dump into a NumPy array, and from there initialise a torch Tensor.

My question is, is this equivalent functionality to TorchVision? i.e. in my use case can I just load image data into tensors without using TorchVision?


torchvision really only uses 8-bit RGB as an intermediate format, as images are usually converted to floating point before being passed to a model with something like to_tensor().

You can also see a typical example of how transformations are applied before being passed to a model in the ImageNet example:

Loading a floating point image should not be an issue. If for some reason you need to use a transform that only works on PIL Images, you can use the to_pil_image function.