Skip to content

Conversation

@maryapp
Copy link
Collaborator

@maryapp maryapp commented Nov 10, 2025

Add Support for Pretrained DeepLabCut Models

issue: #141

Summary

This PR adds support for pretrained DeepLabCut models (e.g. SuperAnimal / Model Zoo) using the existing ModelPoseEstimationTaskPoseEstimation workflow.
No parallel schema is introduced; trained and pretrained models are handled as two modes of the same pipeline.

Key Changes

  • PretrainedModel lookup

    • Registers pretrained models (pretrained_model_name, source, version, species, backbone_model_name, detector_name, default_params, weights_path, description).
    • Helpers: is_pretrained(...), add(...) for explicit registration.
  • Model integration

    • Pretrained models detected via metadata (e.g. _pretrained_model_name in config).
    • Optional helper to insert pretrained models while validating against PretrainedModel.
    • No changes to existing Model schema.
  • PoseEstimation inference

    • Extends make with two code paths:
      • pretrained → _do_pretrained_inference(...)
      • trained → existing logic via do_trained(...)
    • _do_pretrained_inference:
      • Uses PretrainedModel metadata.
      • Calls deeplabcut.video_inference_superanimal(...) when available.
      • Falls back to video_inference(...) where appropriate.
      • Filters kwargs via inspect.signature() to stay API-compatible.

Backward Compatibility

  • Existing trained-model workflows are unchanged.
  • No schema migration required.
  • New behavior is enabled only when a model is explicitly configured as pretrained.

Testing - TODO:

  • Pretrained workflow with a registered SuperAnimal model.
  • Fallback to video_inference when video_inference_superanimal is unavailable.
  • Parameter merging (defaults from PretrainedModel + task overrides).
  • Validation for missing or unregistered pretrained models.

@maryapp maryapp self-assigned this Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants