Fix incorrect rename mapping in modelzoo download - #3452
Conversation
Update `download_super_animal_snapshot` to pass `model_filename` directly as `rename_mapping` when downloading from Hugging Face. This aligns with the expected argument shape and prevents false download failures when validating that the model file exists.
Add module-level logging to PyTorch model zoo inference and emit a warning when video inference produces no pose predictions, making empty-detection runs easier to diagnose.
There was a problem hiding this comment.
Pull request overview
This PR aims to fix SuperAnimal HumanBody checkpoint downloads when the filename fetched from Hugging Face differs from the filename DeepLabCut expects locally, and adds a warning path for empty inference outputs.
Changes:
- Updates the SuperAnimal snapshot download call to alter how
rename_mappingis provided todownload_huggingface_model. - Adds a module logger and a warning when no pose predictions are produced during PyTorch modelzoo video inference.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| deeplabcut/pose_estimation_pytorch/modelzoo/utils.py | Adjusts the download/rename behavior for SuperAnimal snapshot checkpoints. |
| deeplabcut/pose_estimation_pytorch/modelzoo/inference.py | Adds logging and a warning branch for empty prediction results during inference. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Add an explicit source-to-target filename mapping for SuperAnimal models, including `superanimal_humanbody_rtmpose_x`, and pass `rename_mapping` as the expected dict. This ensures snapshots are saved with the standard `<model_name>.pt` filename even when the upstream Hugging Face artifact name differs.
Update superanimal video inference to raise a `RuntimeError` instead of logging a warning when no pose predictions are produced. This makes the failure explicit and prevents downstream processing from continuing with missing detections.
deruyter92
left a comment
There was a problem hiding this comment.
Should we rename on HuggingFace actually to make it more consistent?
Regardless, this would be a good fix.
|
@deruyter92 It would be more robust yes, but then we'd have to undo the fix. Maybe I can check if the filename already matches first? |
Update `download_super_animal_snapshot` to only pass a rename mapping when the Hugging Face source filename differs from the expected local model filename. This avoids unnecessary renaming when the source already matches the `.pt` naming pattern and prevents download failures from mismatched rename rules.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
deeplabcut/pose_estimation_pytorch/modelzoo/inference.py:177
logging/loggerare introduced but currently unused. If you intend to keep them, consider logging the error message at the new "no predictions" failure point (and use an explicit empty-list check). Otherwise, remove the unused import and logger definition.
)
if not predictions:
raise RuntimeError(f"No pose predictions were made for video {video_path}. Were no individuals detected?")
deeplabcut/pose_estimation_pytorch/modelzoo/utils.py:136
- The filename equality check is incorrect:
model_filenamealready includes the.ptsuffix, somodel_filename + ".pt"will never equalsource_filename. This makesrename_mappingnever becomeNoneand obscures the intended logic.
source_filename = MODEL_FILENAME_MAPPING.get(model_name, model_filename)
if model_filename + ".pt" == source_filename:
rename_mapping = None
else:
rename_mapping = {source_filename: model_filename}
Let's keep hugging face as is; renaming breaks backwards compat |
Fix SuperAnimal HumanBody checkpoint downloads when the Hugging Face filename differs from DeepLabCut’s expected filename.
Pass the expected filename directly to download_huggingface_model, allowing it to map the actual downloaded filename, such as rtmpose-x_simcc-body7.pt, to superanimal_humanbody_rtmpose_x.pt. Existing models with matching filenames remain unaffected.
Closes #3450.