mirror of
https://github.com/clearml/clearml
synced 2025-02-01 01:26:49 +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
|
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
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
if isinstance(img_str, bytes):
|
if isinstance(img_str, bytes):
|
||||||
@ -349,7 +349,8 @@ class EventTrainsWriter(object):
|
|||||||
im = Image.open(output)
|
im = Image.open(output)
|
||||||
image = np.asarray(im)
|
image = np.asarray(im)
|
||||||
output.close()
|
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
|
# noinspection PyArgumentList
|
||||||
val = image.reshape(height, width, -1).astype(np.uint8)
|
val = image.reshape(height, width, -1).astype(np.uint8)
|
||||||
else:
|
else:
|
||||||
@ -366,9 +367,11 @@ class EventTrainsWriter(object):
|
|||||||
val = val[:, :, [2, 1, 0]]
|
val = val[:, :, [2, 1, 0]]
|
||||||
else:
|
else:
|
||||||
val = val[:, :, [0, 1, 2]]
|
val = val[:, :, [0, 1, 2]]
|
||||||
except Exception:
|
except Exception as e:
|
||||||
LoggerRoot.get_base_logger(TensorflowBinding).warning('Failed decoding debug image [%d, %d, %d]'
|
logger = LoggerRoot.get_base_logger(TensorflowBinding)
|
||||||
|
logger.warning('Failed decoding debug image [%s, %s, %s]'
|
||||||
% (width, height, color_channels))
|
% (width, height, color_channels))
|
||||||
|
logger.warning('Error: %s' % e)
|
||||||
val = None
|
val = None
|
||||||
return val
|
return val
|
||||||
|
|
||||||
@ -413,9 +416,9 @@ class EventTrainsWriter(object):
|
|||||||
if step % self.image_report_freq != 0:
|
if step % self.image_report_freq != 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
width = img_data['width']
|
width = img_data.get('width', None)
|
||||||
height = img_data['height']
|
height = img_data.get('height', None)
|
||||||
colorspace = img_data['colorspace']
|
colorspace = img_data.get('colorspace', None)
|
||||||
img_str = img_data['encodedImageString']
|
img_str = img_data['encodedImageString']
|
||||||
matrix = self._decode_image(img_str, width=width, height=height, color_channels=colorspace)
|
matrix = self._decode_image(img_str, width=width, height=height, color_channels=colorspace)
|
||||||
if matrix is None:
|
if matrix is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user