Skip to content

Commit 6a2e70e

Browse files
committed
Return zero-pose for top-down models in absence of detections.
When the detector does not detect any crops (with a supra-threshold confidence), no pose-detection is applied and and a zero-vector is returned for the pose-prediction. This solves #137 and copies the already existing intended behavior of returning zeros for empty pose-predictions in single animals.
1 parent f105709 commit 6a2e70e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

dlclive/pose_estimation_pytorch/runner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,13 @@ def get_pose(self, frame: np.ndarray) -> np.ndarray:
195195

196196
frame_batch, offsets_and_scales = self._prepare_top_down(tensor, detections)
197197
if len(frame_batch) == 0:
198-
offsets_and_scales = [(0, 0), 1]
198+
# Determine output shape based on single_animal parameter and n_individuals
199+
if self.single_animal or self.n_individuals == 1:
200+
zero_pose = np.zeros((self.n_bodyparts, 3))
201+
else:
202+
zero_pose = np.zeros((self.n_individuals, self.n_bodyparts, 3))
203+
return zero_pose
204+
199205
tensor = frame_batch # still CHW, batched
200206

201207
if self.dynamic is not None:

0 commit comments

Comments
 (0)