Commit 7956bcdc authored by Yuxin Wu's avatar Yuxin Wu

bugfix in create image summary

parent e35fae5f
...@@ -35,7 +35,7 @@ def create_image_summary(name, val): ...@@ -35,7 +35,7 @@ def create_image_summary(name, val):
""" """
Args: Args:
name(str): name(str):
val(np.ndarray): 4D tensor of NHWC val(np.ndarray): 4D tensor of NHWC. assume RGB if C==3.
Returns: Returns:
tf.Summary: tf.Summary:
...@@ -45,7 +45,8 @@ def create_image_summary(name, val): ...@@ -45,7 +45,8 @@ def create_image_summary(name, val):
s = tf.Summary() s = tf.Summary()
for k in range(n): for k in range(n):
tag = name if n == 1 else '{}/{}'.format(name, k) tag = name if n == 1 else '{}/{}'.format(name, k)
ret, buf = cv2.imencode('.png', val[k]) # imencode assumes BGR
ret, buf = cv2.imencode('.png', val[k, :, :, ::-1])
assert ret, "imencode failed!" assert ret, "imencode failed!"
img = tf.Summary.Image() img = tf.Summary.Image()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment