Skip to content

Commit

Permalink
[Fis] Set _is_init to True when pretrained is True (#555)
Browse files Browse the repository at this point in the history
* set _is_init to True when pretrained is True

* fix comments
  • Loading branch information
HIT-cwh committed Oct 10, 2022
1 parent 6245621 commit 46add35
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mmengine/hub/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ def get_model(cfg_path: str, pretrained: bool = False, **kwargs):
model = MODELS.build(cfg.model, default_args=kwargs)
if pretrained:
load_checkpoint(model, cfg.model_path)
# Hack to use pretrained weights.
# If we do not set _is_init here, Runner will call
# `model.init_weights()` to overwrite the pretrained model.
model._is_init = True
return model

0 comments on commit 46add35

Please sign in to comment.