Skip to content
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

Saving Trained Model #4

Closed
michael-camilleri opened this issue Apr 5, 2022 · 3 comments
Closed

Saving Trained Model #4

michael-camilleri opened this issue Apr 5, 2022 · 3 comments

Comments

@michael-camilleri
Copy link

Hi Gorjan

Once trained, how can I save a CACNF model? does setting the save_model_path store also the backbones (including the fine-tuned Resnet) or do I need to store these (and load them) separately using the resnet_model_path and save_backbone_path?

@gorjanradevski
Copy link
Owner

Hi Michael, using the save_model_path saves the whole model, including the classifier, useful if you want to use the same model for inference. The save_backbone_path, saves the whole model, excluding the classifier. Useful if you want to fine-tune the backbone on a different dataset, with different number of classes.

When performing inference, you should create the model model = CrossAttentionCentralNetFusion, and then load the full model that you saved with save_model_path (see inference.py). On the other hand, if you just want to load the backbone, and have a randomly initialized classifier with different number of classes, you can provide the load_backbone_path and set freeze_backbone to True or False, in case you want to fine-tune the backbone or not, respectively.

The fact that you need to always provide the resnet_model_path when creating a model is poor API design, but didn't have time to think about a workaround. Ideally, if you want to load either a backbone, or a full model, you should not be obliged to provide the resnet_model_path.

@michael-camilleri
Copy link
Author

As long as the resnet is still loaded correctly, I don't mind passing a path.

@gorjanradevski
Copy link
Owner

I'm closing this issue, feel free to reopen if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants