Skip to content

Commit 633b3cf

Browse files
No public description
PiperOrigin-RevId: 595901724
1 parent 7d8a218 commit 633b3cf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

official/vision/utils/object_detection/visualization_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,11 @@ def _denormalize_images(images: tf.Tensor) -> tf.Tensor:
969969
)
970970
return tf.cast(images, dtype=tf.uint8)
971971

972+
if images.shape[3] > 3:
973+
images = images[:, :, :, 0:3]
974+
elif images.shape[3] == 1:
975+
images = tf.image.grayscale_to_rgb(images)
976+
972977
images = tf.nest.map_structure(
973978
tf.identity,
974979
tf.map_fn(
@@ -981,10 +986,6 @@ def _denormalize_images(images: tf.Tensor) -> tf.Tensor:
981986
),
982987
)
983988

984-
if images.shape[3] > 3:
985-
images = images[:, :, :, 0:3]
986-
elif images.shape[3] == 1:
987-
images = tf.image.grayscale_to_rgb(images)
988989
if true_image_shape is None:
989990
true_shapes = tf.constant(-1, shape=[images.shape.as_list()[0], 3])
990991
else:

0 commit comments

Comments
 (0)