I’m not sure to understand the question completely, so please feel free to correct my understanding.



 dachosen1:

Does Pytorch have a function to decode a PNG image to a uint8 or uint16 tensor?


PyTorch, or rather torchvision, uses PIL as the default library to load and manipulate images.
PIL is able to load PNG files and the numpy array can be transformed to a tensor afterwards.



 dachosen1:

I found a way in Tensorflow to that converts the matplotlib plot specified by ‘figure’ to a PNG image, wanted to see if there was an equivalent for Pytorch.


You can store matplotlib images directly as PNGs using matplotlib.pyplot.savefig.