MONAI
MONAI copied to clipboard
Add integration with HF Hub
Description
Hi! Amazing repo!
I made a draft with PytorchModelHubMixin for a few models in the repo. This mixin adds a few methods to make it possible to save/load models and share them with the HF hub.
Here is a short example:
from monai.networks.nets import AHNet
net = AHNet()
# save to a local folder
net.save_pretrained("qubvel-hf/ahnet")
# push to HF hub
net.push_to_hub("qubvel-hf/ahnet")
# load form local folder or HF hub
net = AHNet.from_pretrained("qubvel-hf/ahnet")
I believe the repo and community may benefit from sharing pretrained models built with this framework! Let me know if it aligns with your roadmap, I will be happy to help you with implementation or to complete the PR!
Types of changes
- [x] Non-breaking change (fix or new feature that would not break existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running
./runtests.sh -f -u --net --coverage
. - [x] Quick tests passed locally by running
./runtests.sh --quick --unittests --disttests
. - [ ] In-line docstrings updated.
- [ ] Documentation updated, tested
make html
command in thedocs/
folder.