Skip to content

Fix the default crop size for top-down RTMPose-X - #3593

Merged
deruyter92 merged 4 commits into
DeepLabCut:devfrom
AtomicGlance:fix-3592-rtmpose-top-down-crop
Nov 23, 2026
Merged

deruyter92 merged 4 commits into
DeepLabCut:devfrom
AtomicGlance:fix-3592-rtmpose-top-down-crop

Conversation

@AtomicGlance

@AtomicGlance AtomicGlance commented Nov 17, 2026 •

Copy link
Copy Markdown

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.

@deruyter92 deruyter92 self-assigned this Nov 17, 2026
@deruyter92 deruyter92 added bug fix config Related to config.yaml, ruamel, YAML parsing, ... labels Nov 17, 2026
@deruyter92
deruyter92 changed the base branch from main to dev November 17, 2026 13:38
AtomicGlance and others added 3 commits November 19, 2026 15:03
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
@deruyter92
deruyter92 force-pushed the fix-3592-rtmpose-top-down-crop branch from 67c1bdd to 09d745f Compare November 19, 2026 14:12
@deruyter92

Copy link
Copy Markdown
Collaborator

@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 Task.TOP_DOWN as you suggested, I'd prefer restoring the single merge order used before 3.0.1 (base < task augmentations < model config) for every task.

I pushed this to your branch and rebased it onto dev. Let me know if anything looks off!

@deruyter92
deruyter92 requested review from Ayskin and C-Achard and a balanced review from Copilot November 19, 2026 14:15

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.

🟡 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

@C-Achard C-Achard left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@AtomicGlance, looks good to me! Thanks for the additional fix and in general for the contribution. Good PR

@deruyter92

Copy link
Copy Markdown
Collaborator

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.

@C-Achard, Good suggestion. Addressed in #3598

@AtomicGlance

Copy link
Copy Markdown
Author

@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

@AtomicGlance

Copy link
Copy Markdown
Author

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.

@C-Achard, Good suggestion. Addressed in #3598

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!

@deruyter92
deruyter92 merged commit 9bf3dc9 into DeepLabCut:dev Nov 23, 2026
37 checks passed
@Ayskin Ayskin added the 3.0.4 label Nov 26, 2026
deruyter92 added a commit to Ayskin/DeepLabCut that referenced this pull request Dec 1, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0.4 bug fix config Related to config.yaml, ruamel, YAML parsing, ... pytorch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default top-down rtmpose_x config: top_down_crop 256 but head input_size 384, training crashes at first step

5 participants