Skip to content

Commit 849eac7

Browse files
committed
Add informative error when model is not loaded. ( + improve docstring)
1 parent c618a7f commit 849eac7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

dlclive/pose_estimation_pytorch/runner.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ class PyTorchRunner(BaseRunner):
132132
Processors that were implemented.
133133
dynamic: Whether to use dynamic cropping.
134134
top_down_config: Only for top-down models running with a detector.
135+
136+
returns:
137+
pose: The pose of the animal(s) in the frame.
138+
shape:
139+
(n_bodyparts, 3) if single_animal is True
140+
(n_individuals, n_bodyparts, 3) if single_animal is False.
141+
If no detections are found, the pose consists of zeros.
142+
143+
Raises:
144+
ValueError: If the model is not loaded. Call load_model() or init_inference() before calling get_pose().
135145
"""
136146

137147
def __init__(
@@ -182,6 +192,10 @@ def close(self) -> None:
182192

183193
@torch.inference_mode()
184194
def get_pose(self, frame: np.ndarray) -> np.ndarray:
195+
if self.model is None:
196+
raise ValueError(
197+
"Model not loaded. Call load_model() or init_inference() before calling get_pose()."
198+
)
185199
c, h, w = frame.shape
186200
tensor = torch.from_numpy(frame).permute(2, 0, 1) # CHW, still on CPU
187201

0 commit comments

Comments
 (0)