Multichannel numpy array to PIL image I have a 4 channel Numpy image that needs to be converted to PIL image in order implement torchvision transformations on image. But when I try to do this using PIL.Image.from_array(&lt;my_numpy_image&gt;) I get the following error.

TypeError: Cannot handle this data type

I cannot loose and get rid of any channel information right now so won't be able to discard any channels.
Try specifying mode so that PIL is aware of data format.

img = Image.fromarray(source_array, mode="CMYK")


If that does not work, what is the shape of source array ?