tensorboard icon indicating copy to clipboard operation
tensorboard copied to clipboard

make_image: reshape tensor for Grayscale image

Open YujiOshima opened this issue 7 years ago • 0 comments

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]

YujiOshima avatar Feb 28 '18 06:02 YujiOshima