Skip to content

Commit

Permalink
Merge pull request #2142 from huggingface/fix_hrnet_head
Browse files Browse the repository at this point in the history
Fix #2139, disable strict weight loading when head changes from classification
  • Loading branch information
rwightman authored Apr 9, 2024
2 parents 59b3d86 + 17b892f commit 9531eb7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion timm/models/hrnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,17 @@ def _create_hrnet(variant, pretrained=False, cfg_variant=None, **model_kwargs):
kwargs_filter = ('num_classes', 'global_pool')
features_only = True
cfg_variant = cfg_variant or variant

pretrained_strict = model_kwargs.pop(
'pretrained_strict',
not features_only and model_kwargs.get('head', 'classification') == 'classification'
)
model = build_model_with_cfg(
model_cls,
variant,
pretrained,
model_cfg=cfg_cls[cfg_variant],
pretrained_strict=not features_only,
pretrained_strict=pretrained_strict,
kwargs_filter=kwargs_filter,
**model_kwargs,
)
Expand Down

0 comments on commit 9531eb7

Please sign in to comment.