Skip to content

Commit

Permalink
Image Summary: Officially start using vectorized EncodePng Op (#6611)
Browse files Browse the repository at this point in the history
See #6344 for context.

Googlers, see b/276803093 for more details.

Tested internally: cl/570508513

#oncall #summary #image
  • Loading branch information
yatbear authored Oct 4, 2023
1 parent a718ebc commit d295fad
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions tensorboard/plugins/image/summary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,7 @@ def lazy_tensor():
tf.debugging.assert_non_negative(max_outputs)
images = tf.image.convert_image_dtype(data, tf.uint8, saturate=True)
limited_images = images[:max_outputs]
if tf.compat.forward_compatible(2023, 5, 1):
encoded_images = tf.image.encode_png(limited_images)
else:
# TODO(b/276803093): The kernel was updated around 2023/04/15.
# After 90 days (2023/07/15), please remove the False branch.
encoded_images = tf.map_fn(
tf.image.encode_png,
limited_images,
dtype=tf.string,
name="encode_each_image",
)
# Workaround for map_fn returning float dtype for an empty
# elems input.
encoded_images = tf.cond(
tf.shape(input=encoded_images)[0] > 0,
lambda: encoded_images,
lambda: tf.constant([], tf.string),
)
encoded_images = tf.image.encode_png(limited_images)
image_shape = tf.shape(input=images)
dimensions = tf.stack(
[
Expand Down

0 comments on commit d295fad

Please sign in to comment.