Skip to content

Commit

Permalink
Merge pull request #33 from kohr-h/lazy_pil_import
Browse files Browse the repository at this point in the history
Make PIL import lazy
  • Loading branch information
lanpa committed Sep 24, 2017
2 parents 3e3c98c + 878c547 commit 3eac9b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tensorboardX/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import bisect
from six import StringIO
from six.moves import range
from PIL import Image
import numpy as np
# pylint: disable=unused-import
from .src.summary_pb2 import Summary
Expand Down Expand Up @@ -164,6 +163,7 @@ def image(tag, tensor):

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)
import io
Expand Down
2 changes: 2 additions & 0 deletions tensorboardX/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ def add_histogram(self, tag, values, global_step=None, bins='tensorflow'):
def add_image(self, tag, img_tensor, global_step=None):
"""Add image data to summary.
Note that this requires the ``pillow`` package.
Args:
tag (string): Data identifier
img_tensor (torch.Tensor): Image data
Expand Down

0 comments on commit 3eac9b5

Please sign in to comment.