This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"joints_vis": [ | |
1, | |
1, | |
1, | |
1, | |
1, | |
1, | |
1, | |
1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# avoid invisible keypoints whose value are <= 0 | |
masked_keypoint_x = tf.boolean_mask(keypoint_x, keypoint_x > 0) | |
masked_keypoint_y = tf.boolean_mask(keypoint_y, keypoint_y > 0) | |
# find \left-most, top, bottom, and right-most keypoints | |
keypoint_xmin = tf.reduce_min(masked_keypoint_x) | |
keypoint_xmax = tf.reduce_max(masked_keypoint_x) | |
keypoint_ymin = tf.reduce_min(masked_keypoint_y) | |
keypoint_ymax = tf.reduce_max(masked_keypoint_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scale = 1 | |
size = 6 * sigma + 1 | |
x, y = tf.meshgrid(tf.range(0, 6*sigma+1, 1), tf.range(0, 6*sigma+1, 1), indexing='xy') | |
# the center of the gaussian patch should be 1 | |
center_x = size // 2 | |
center_y = size // 2 | |
# generate this 7x7 gaussian patch | |
gaussian_patch = tf.cast(tf.math.exp(-(tf.square(x - center_x) + tf.math.square(y - center_y)) / (tf.math.square(sigma) * 2)) * scale, dtype=tf.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vanilla version | |
loss += tf.math.reduce_mean(tf.math.square(labels - output)) | |
# improved version | |
weights = tf.cast(labels > 0, dtype=tf.float32) * 81 + 1 | |
loss += tf.math.reduce_mean(tf.math.square(labels - output) * weights) |
OlderNewer