Skip to content

Add a range of features for augmentation and training, and fix a few bugs#3263

Open
chris-rapson-hectre wants to merge 34 commits into
open-mmlab:mainfrom
chris-rapson-hectre:flip_rotate_EarlyStopping_Unfreeze_visualization
Open

Add a range of features for augmentation and training, and fix a few bugs#3263
chris-rapson-hectre wants to merge 34 commits into
open-mmlab:mainfrom
chris-rapson-hectre:flip_rotate_EarlyStopping_Unfreeze_visualization

Conversation

@chris-rapson-hectre

@chris-rapson-hectre chris-rapson-hectre commented Apr 12, 2026

Copy link
Copy Markdown

Motivation

Improve augmentation and training for our model, and hopefully others' models as well.

Modification

  • generalise the heatmap loss calculated in ae_head to have the correct dimensions
  • new augmentations: bidirectional flip and rotation by Nx90º
  • visualisation to debug augmentations
  • add a hook to initially freeze and then unfreeze the backbone, for safer fine tuning
  • add a hook for early stopping
  • bug fix for singular Hessian matrices (e.g. a constant heatmap)

BC-breaking (Optional)

No

Use cases (Optional)

  1. associative embedding training failed for me because of a shape mismatch with the keypoint_weights
  2. more augmentations are always helpful
  3. verifying that augmentations are working as expected helps to debug algorithms and tune hyperparameters
  4. pretrained backbones can be vulnerable to large losses during the first few iterations when fine tuning, so it's good to freeze them initially and then allow them to adapt later
  5. stop the training when the model starts to overfit to avoid wasting GPU resouce
  6. using pinv instead of inv means the typical case is unchanged and avoids crashing on a pathological edge case.

Checklist

Before PR:

  • [y ] I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • [ y] Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • [ y] Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • [y ] New functionalities are covered by complete unit tests. If not, please add more unit tests to ensure correctness.
  • [n ] The documentation has been modified accordingly, including docstring or example tutorials.

The only documentation in this PR is as docstrings. Please let me know if you want more.

After PR:

  • CLA has been signed and all committers have signed the CLA in this PR.

chris-rapson-hectre and others added 29 commits April 8, 2026 14:30
@CLAassistant

CLAassistant commented Apr 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment on lines +1402 to +1403
else:
results['img_mask'] = np.ascontiguousarray(np.rot90(results['img_mask'], k=k))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indent the else block.

self.backbone_stages = backbone_stages

def before_run(self, runner: Runner):
model = runner.model

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These lines were added in other repo:

Suggested change
model = runner.model
assert hasattr(runner, 'epoch'), 'Runner must have an epoch attribute'
assert hasattr(runner.model, 'backbone'), 'Model must have a backbone attribute'
model = runner.model

Comment thread mmpose/engine/hooks/unfreeze_backbone_hook.py Outdated
Comment thread tests/test_engine/test_hooks/test_unfreeze_backbone_hook.py Outdated
Comment thread tests/test_engine/test_hooks/test_unfreeze_backbone_hook.py Outdated
Comment thread tests/test_engine/test_hooks/test_visualization_hooks.py
chris-rapson-hectre and others added 5 commits April 20, 2026 10:19
mock logger argument to Runner

Co-authored-by: chanul-hectre <chanul@hectre.com>
Move handling of DistributedDataParallel wrapper earlier

Co-authored-by: chanul-hectre <chanul@hectre.com>
set epoch=0 for unfreezing tests

Co-authored-by: chanul-hectre <chanul@hectre.com>
set epoch=0 for unfreezing tests

Co-authored-by: chanul-hectre <chanul@hectre.com>
* indentation for else block
* check runner and model attributes, fail early with err msg
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.

3 participants