-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load weights on segmentation/train.py when using --resume and --test-only flags #3285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few notes on the implementation:
optimizer.load_state_dict(checkpoint['optimizer']) | ||
lr_scheduler.load_state_dict(checkpoint['lr_scheduler']) | ||
args.start_epoch = checkpoint['epoch'] + 1 | ||
model_without_ddp.load_state_dict(checkpoint['model'], strict=not args.test_only) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strict=False
required to avoid having to configure auxiliary classifiers
args.start_epoch = checkpoint['epoch'] + 1 | ||
model_without_ddp.load_state_dict(checkpoint['model'], strict=not args.test_only) | ||
if not args.test_only: | ||
optimizer.load_state_dict(checkpoint['optimizer']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid loading the weights of other objects if in test-only mode. Similar to the above, this is done to avoid having to handle auxiliary classifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for improving this Vasilis!
Summary: Co-authored-by: Francisco Massa <fvsmassa@gmail.com> Reviewed By: datumbox Differential Revision: D26156373 fbshipit-source-id: 83f22c90477ca2da8db176d2455a70ca302d17d1
A good way to verify the accuracy of a specific epoch checkpoint on the evaluation dataset is to execute:
This is supported on both the classification and detection reference scripts but not on segmentation. More specifically on segmentation, the specified weights are not loaded and thus we report the accuracy of randomly initialized weights. This PR fixes this.