Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

make_image: reshape tensor for Grayscale image #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YujiOshima
Copy link

PIL.fromarray function cannot handle channel==1.
TypeError has occurred.

from PIL import Image
import numpy as np
arr = np.random.rand(100,100,1)
image = Image.fromarray(arr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 2426, in fromarray
    raise TypeError("Cannot handle this data type")
TypeError: Cannot handle this data type

The tensor should be reshaped to 2D.

Signed-off-by: YujiOshima [email protected]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant