Skip to content

Instantly share code, notes, and snippets.

@Y-T-G
Created November 25, 2023 06:17
Show Gist options
  • Save Y-T-G/54225c5a0037f38a6255685b5df13f26 to your computer and use it in GitHub Desktop.
Save Y-T-G/54225c5a0037f38a6255685b5df13f26 to your computer and use it in GitHub Desktop.
Reinitializing MMDetection model in Runner without reloading data.
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