Skip to content

Commit 37f094d

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 021be9d commit 37f094d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dlclive/pose_estimation_pytorch/runner.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,14 @@ def get_pose(self, frame: np.ndarray) -> np.ndarray:
202202

203203
frame_batch, offsets_and_scales = self._prepare_top_down(tensor, detections)
204204
if len(frame_batch) == 0:
205-
offsets_and_scales = [(0, 0), 1]
206-
else:
207-
tensor = frame_batch # still CHW, batched
205+
zero_pose = (
206+
np.zeros((self.n_bodyparts, 3))
207+
if self.n_individuals < 2 else
208+
np.zeros((self.n_individuals, self.n_bodyparts, 3))
209+
)
210+
return zero_pose
211+
212+
tensor = frame_batch # still CHW, batched
208213

209214
if self.dynamic is not None:
210215
tensor = self.dynamic.crop(tensor)

0 commit comments

Comments
 (0)