Commit 27289f90 authored by Yu-hui Chen's avatar Yu-hui Chen Committed by TF Object Detection Team
Browse files

Fixed the bug caused by cl/337432623 in the refine_keypoint function. That CL

causes different behaviors with NaNs in reduce_min/argmin functions. Replaced
the NaN values by Infs in one of the tensor to fix it.

PiperOrigin-RevId: 338069303
parent eea69e20
...@@ -674,6 +674,11 @@ def refine_keypoints(regressed_keypoints, keypoint_candidates, keypoint_scores, ...@@ -674,6 +674,11 @@ def refine_keypoints(regressed_keypoints, keypoint_candidates, keypoint_scores,
sqrd_distances = tf.math.reduce_sum(tf.multiply(diff, diff), axis=-1) sqrd_distances = tf.math.reduce_sum(tf.multiply(diff, diff), axis=-1)
distances = tf.math.sqrt(sqrd_distances) distances = tf.math.sqrt(sqrd_distances)
# Replace the NaNs with Infs to make sure the following reduce_min/argmin
# behaves properly.
distances = tf.where(
tf.math.is_nan(distances), np.inf * tf.ones_like(distances), distances)
# Determine the candidates that have the minimum distance to the regressed # Determine the candidates that have the minimum distance to the regressed
# keypoints. Shape [batch_size, num_instances, num_keypoints]. # keypoints. Shape [batch_size, num_instances, num_keypoints].
min_distances = tf.math.reduce_min(distances, axis=2) min_distances = tf.math.reduce_min(distances, axis=2)
......
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