Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions deeplabcut/pose_estimation_pytorch/modelzoo/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Licensed under GNU Lesser General Public License v3.0
#
import json
import logging
from pathlib import Path

import numpy as np
Expand All @@ -30,6 +31,8 @@
)
from deeplabcut.utils.make_labeled_video import create_video

logger = logging.getLogger(__name__)


class NumpyEncoder(json.JSONEncoder):
"""Special json encoder for numpy types."""
Expand Down Expand Up @@ -170,6 +173,8 @@ def _video_inference_superanimal(
pose_runner=pose_runner,
detector_runner=detector_runner,
)
if not predictions:
raise RuntimeError(f"No pose predictions were made for video {video_path}. Were no individuals detected?")

bbox_keys_in_predictions = {"bboxes", "bbox_scores"}
bboxes_list = [
Expand Down
10 changes: 9 additions & 1 deletion deeplabcut/pose_estimation_pytorch/modelzoo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@

# COCO category ID for the "person" class.
COCO_PERSON_CATEGORY_ID = 1
MODEL_FILENAME_MAPPING = {
"superanimal_humanbody_rtmpose_x": "rtmpose-x_simcc-body7.pt",
}


def get_model_configs_folder_path() -> Path:
Expand Down Expand Up @@ -126,10 +129,15 @@ def download_super_animal_snapshot(dataset: str, model_name: str) -> Path:
model_filename = f"{model_name}.pt"
model_path = snapshot_dir / model_filename

source_filename = MODEL_FILENAME_MAPPING.get(model_name, model_filename)
if model_filename == source_filename:
rename_mapping = None
else:
rename_mapping = {source_filename: model_filename}
download_huggingface_model(
model_name,
target_dir=str(snapshot_dir),
rename_mapping={model_filename: model_filename},
rename_mapping=rename_mapping,
)
Comment thread
C-Achard marked this conversation as resolved.
if not model_path.exists():
raise RuntimeError(f"Failed to download {model_name} to {model_path}")
Expand Down
Loading