Skip to content

Commit 37def73

Browse files
committed
Update scores computation
1 parent 4c7ab31 commit 37def73

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/python/model_api/models/keypoint_detection.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,31 @@ def _decode_simcc(
141141
simcc_y: np.ndarray,
142142
simcc_split_ratio: float = 2.0,
143143
apply_softmax: bool = False,
144+
decode_beta: float = 150.0,
145+
sigma: float | int = 6.0,
144146
) -> tuple[np.ndarray, np.ndarray]:
145147
"""Decodes keypoint coordinates from SimCC representations. The decoded coordinates are in the input image space.
146148
147149
Args:
148150
simcc_x (np.ndarray): SimCC label for x-axis
149151
simcc_y (np.ndarray): SimCC label for y-axis
150152
simcc_split_ratio (float): The ratio of the label size to the input size.
151-
apply_softmax (bool): whether to apply softmax on the heatmap.
153+
apply_softmax (bool): whether to apply softmax during scores generation.
152154
Defaults to False.
155+
decode_beta (float): The beta value for decoding scores with softmax. Defaults
156+
to 150.0.
157+
sigma (float | int): The sigma value in the Gaussian SimCC
158+
label. Defaults to 6.0
153159
154160
Returns:
155161
tuple:
156162
- keypoints (np.ndarray): Decoded coordinates in shape (N, K, D)
157163
- scores (np.ndarray): The keypoint scores in shape (N, K).
158164
It usually represents the confidence of the keypoint prediction
159165
"""
160-
keypoints, scores = _get_simcc_maximum(simcc_x, simcc_y, apply_softmax)
166+
keypoints, scores = _get_simcc_maximum(simcc_x, simcc_y)
167+
if apply_softmax:
168+
_, scores = _get_simcc_maximum(decode_beta * sigma * simcc_x, decode_beta * sigma * simcc_y, apply_softmax)
161169

162170
# Unsqueeze the instance dimension for single-instance results
163171
if keypoints.ndim == 2:

0 commit comments

Comments
 (0)