mirror of
https://github.com/clearml/clearml
synced 2025-01-31 17:17:00 +00:00
Fix in saving image summary in tensorflow bindings
This commit is contained in:
parent
772fd7f750
commit
dc036fd51d
@ -338,7 +338,7 @@ class EventTrainsWriter(object):
|
||||
histogram_granularity=histogram_granularity
|
||||
)
|
||||
|
||||
def _decode_image(self, img_str, width, height, color_channels):
|
||||
def _decode_image(self, img_str, width=None, height=None, color_channels=None):
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
if isinstance(img_str, bytes):
|
||||
@ -349,7 +349,8 @@ class EventTrainsWriter(object):
|
||||
im = Image.open(output)
|
||||
image = np.asarray(im)
|
||||
output.close()
|
||||
if height > 0 and width > 0:
|
||||
if height is not None and width is not None:
|
||||
assert height > 0 and width > 0, 'Image width and height params are not positive'
|
||||
# noinspection PyArgumentList
|
||||
val = image.reshape(height, width, -1).astype(np.uint8)
|
||||
else:
|
||||
@ -366,9 +367,11 @@ class EventTrainsWriter(object):
|
||||
val = val[:, :, [2, 1, 0]]
|
||||
else:
|
||||
val = val[:, :, [0, 1, 2]]
|
||||
except Exception:
|
||||
LoggerRoot.get_base_logger(TensorflowBinding).warning('Failed decoding debug image [%d, %d, %d]'
|
||||
except Exception as e:
|
||||
logger = LoggerRoot.get_base_logger(TensorflowBinding)
|
||||
logger.warning('Failed decoding debug image [%s, %s, %s]'
|
||||
% (width, height, color_channels))
|
||||
logger.warning('Error: %s' % e)
|
||||
val = None
|
||||
return val
|
||||
|
||||
@ -413,9 +416,9 @@ class EventTrainsWriter(object):
|
||||
if step % self.image_report_freq != 0:
|
||||
return None
|
||||
|
||||
width = img_data['width']
|
||||
height = img_data['height']
|
||||
colorspace = img_data['colorspace']
|
||||
width = img_data.get('width', None)
|
||||
height = img_data.get('height', None)
|
||||
colorspace = img_data.get('colorspace', None)
|
||||
img_str = img_data['encodedImageString']
|
||||
matrix = self._decode_image(img_str, width=width, height=height, color_channels=colorspace)
|
||||
if matrix is None:
|
||||
|
Loading…
Reference in New Issue
Block a user