Repository navigation
Fix the default crop size for top-down RTMPose-X - #3593
Conversation
DeepLabCut#3198 let the generic aug defaults override the model YAML's `data` section (3.0.1/3.0.2), breaking crop sizes for rtmpose_x and CTD models (DeepLabCut#3592) and CTD bbox_margin.
…head input size Configs created with 3.0.1/3.0.2 for some RTMPose models have a top_down_crop that differs from the head's input_size. see DeepLabCut#3592
67c1bdd to
09d745f
Compare
|
@AtomicGlance, thanks for tracking this down. Your diagnosis is correct. The root cause is a regression from the config migration (#3198): the merge order of the generic augmentation defaults and the model YAML was flipped for all tasks, not just top-down. Besides top-down rtmpose_x, this also affects the CTD models. So rather than special-casing I pushed this to your branch and rebased it onto dev. Let me know if anything looks off! |
There was a problem hiding this comment.
🟡 Changes recommended
The merge changes conditional top-down crop sizes and bounding-box margins despite claiming those paths are unchanged, so the description or precedence logic needs correction.
1 open issue
What changed in this PR
Fixes #3592 by preserving model-specific crop sizes in DeepLabCut’s PyTorch configuration builder and repairing crop/head mismatches when loading configs.
Changes:
- Applies model settings after shared augmentation defaults.
- Aligns train and inference crops with fixed head input sizes, logging adjustments.
- Adds regression coverage for RTMPose-X crop repair and model-specific data precedence.
| File | Description |
|---|---|
tests/pose_estimation_pytorch/config/test_pose_config_creation.py |
Tests crop repair and model-data precedence. |
deeplabcut/pose_estimation_pytorch/config/pose.py |
Repairs crops that differ from fixed head input sizes. |
deeplabcut/pose_estimation_pytorch/config/make_pose_config.py |
Gives model settings precedence over augmentation defaults. |
Review effort: Balanced
There was a problem hiding this comment.
Just a few comments @deruyter92, apart from the PR desc needing an update and these, should be good.
On a higher level the, model_cfg = _update_config(_update_config(base_cfg, aug_cfg), model_cfg) nesting I'm not very fond of; maybe we could put this in a more explicit wrapper/helper in a future PR.
Maybe with an explicit shape e.g. like override_cfg(base_cfg, override_with=new_cfg) with a required kwarg, for clarity.
deruyter92
left a comment
There was a problem hiding this comment.
@AtomicGlance, looks good to me! Thanks for the additional fix and in general for the contribution. Good PR
Appreciate it, great job you guys are doing |
Hi Jaap, thanks again for reviewing this! Just a quick nudge on the merge when you have a chance. Hope your week’s off to a good start! |
Replace the nested `_update_config(_update_config(base, aug), model)` call with two `_override_config(base, override_with=...)` steps, so the merge order (base < task augmentations < model config) is readable at the call site. `override_with` must be passed by keyword. The helper deep-copies both inputs and wraps `_update_config`, so merge behaviour is unchanged. The detector default merge uses it too. The deprecated public `update_config` is unchanged. Follow-up to review on DeepLabCut#3593.

Fixes #3592. Shared augmentation defaults were overwriting model-specific settings. The config builder now applies base defaults, then shared augmentations, then model settings. This applies to all pose models, including conditional top-down (CTD), following @deruyter92's change in f1ec777. RTMPose-X now gets its intended 384 × 384 training and inference crops. CTD models also keep their declared values; for example, ctd_coam_w48_human uses a 288 × 384 crop and a bounding-box margin of 5.
When a loaded config has a crop that does not match a fixed-size head, the loader adjusts the in-memory config and explains what to change in the saved YAML. The precedence test checks the merged defaults before validation, so that repair cannot mask a merge-order regression.
Validation on the updated branch: 368 configuration tests passed, and pre-commit passed on both files changed in the review follow-up. Full training and the full repository suite were not run locally.