From 7e864b699c29f48c7e6a0f50797a605103f5e603 Mon Sep 17 00:00:00 2001 From: YujiOshima Date: Wed, 28 Feb 2018 06:21:08 +0000 Subject: [PATCH] make_image: reshape tensor at Grayscale image Signed-off-by: YujiOshima --- python/tensorboard/summary.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/tensorboard/summary.py b/python/tensorboard/summary.py index ba7dd67..e56ee76 100644 --- a/python/tensorboard/summary.py +++ b/python/tensorboard/summary.py @@ -164,7 +164,10 @@ def make_image(tensor): """Convert an numpy representation image to Image protobuf""" from PIL import Image height, width, channel = tensor.shape - image = Image.fromarray(tensor) + if channel == 1: + image = Image.fromarray(tensor.reshape(height, width)) + else: + image = Image.fromarray(tensor) import io output = io.BytesIO() image.save(output, format='PNG')