Skip to content

Fix incorrect rename mapping in modelzoo download - #3452

Open
C-Achard wants to merge 7 commits into
mainfrom
cy/fix-modelzoo-humanbody-download
Open

Fix incorrect rename mapping in modelzoo download#3452
C-Achard wants to merge 7 commits into
mainfrom
cy/fix-modelzoo-humanbody-download

Conversation

@C-Achard

Copy link
Copy Markdown
Collaborator

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.

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.
@C-Achard
C-Achard requested a lite review from Copilot August 14, 2026 13:07
@C-Achard C-Achard self-assigned this Aug 14, 2026
@C-Achard C-Achard added bug fix! fix for a real buggy one... ModelZoo related to models/code for modezoo.deeplabcut.org huggingface labels Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mapping is provided to download_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.

Comment thread deeplabcut/pose_estimation_pytorch/modelzoo/utils.py
Comment thread deeplabcut/pose_estimation_pytorch/modelzoo/inference.py
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.
@C-Achard
C-Achard marked this pull request as ready for review August 17, 2026 08:42
@deruyter92
deruyter92 self-requested a review August 18, 2026 05:42

@deruyter92 deruyter92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename on HuggingFace actually to make it more consistent?
Regardless, this would be a good fix.

@C-Achard

Copy link
Copy Markdown
Collaborator Author

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/logger are 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_filename already includes the .pt suffix, so model_filename + ".pt" will never equal source_filename. This makes rename_mapping never become None and 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}

@MMathisLab

Copy link
Copy Markdown
Member

Should we rename on HuggingFace actually to make it more consistent?
Regardless, this would be a good fix.

Let's keep hugging face as is; renaming breaks backwards compat

@deruyter92 deruyter92 added the 3.1 label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.1 bug fix! fix for a real buggy one... huggingface ModelZoo related to models/code for modezoo.deeplabcut.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

superanimal_humanbody_rtmpose_x download fails

4 participants