Created
November 25, 2023 06:17
-
-
Save Y-T-G/54225c5a0037f38a6255685b5df13f26 to your computer and use it in GitHub Desktop.
Reinitializing MMDetection model in Runner without reloading data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init_model(runner): | |
""" | |
Initializes a new model for the next training cycle. | |
Args: | |
runner (Runner): Runner object. | |
Returns: | |
runner (Runner): Runner object with initialized model. | |
""" | |
# Reset the optimizer and scheduler | |
runner.optim_wrapper = runner.cfg.optim_wrapper | |
runner.param_schedulers = runner.cfg.param_scheduler | |
# Build a new model | |
runner.model = runner.build_model(runner.cfg.model) | |
runner.model = runner.wrap_model( | |
runner.cfg.get('model_wrapper_cfg'), runner.model) | |
return runner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment