mlcommons / GaNDLF

A generalizable application framework for segmentation, regression, and classification using PyTorch
https://gandlf.org
Apache License 2.0
150 stars 78 forks source link

Make sure Hugging Face downloads work, better discoverability #878

Closed NielsRogge closed 1 month ago

NielsRogge commented 1 month ago

Hi @sarthakpati and team,

Thanks for this nice work! I wrote a quick PoC to showcase that you can easily have integration with the 🤗 hub so that you can automatically load the various GaNDLF models using from_pretrained (and push them using push_to_hub), track download numbers for your models (similar to models in the Transformers library), and have nice model cards on a per-model basis. It leverages the PyTorchModelHubMixin class which allows to inherits these methods.

Usage is as follows:

from .models import DenseNet

model = DenseNet(...)

# optionally, one can push a trained model to the hub at the end of training
model.push_to_hub("nielsr/densenet-finetuned-medical-segmentation")

# reload as follows
model = DenseNet.from_pretrained("nielsr/densenet-finetuned-medical-segmentation")

Alternatively, if you want a more custom integration with the hub, we also provide methods like hf_hub_download (to download a file from the hub, upload_folder and upload_file). Those require some more work however to make download stats work.

This means people don't need to manually download a checkpoint first in their local environment, it just loads automatically from the hub.

Would you be interested in this integration?

Fixes https://github.com/mlcommons/GaNDLF/issues/727

Kind regards,

Niels

github-actions[bot] commented 1 month ago

MLCommons CLA bot:
Thank you very much for your submission, we really appreciate it. Before we can accept your contribution, we ask that you sign the MLCommons CLA (Apache 2). Please use this [Google form] (https://forms.gle/Ew1KkBVpyeJDuRw67) to initiate authorization. If you are from an MLCommons member organization, we will request that you be added to the CLA. If you are not from a member organization, we will email you a CLA to sign. For any questions, please contact support@mlcommons.org.
0 out of 1 committers have signed the MLCommons CLA.
:x: @NielsRogge
You can retrigger this bot by commenting recheck in this Pull Request

sarthakpati commented 1 month ago

Thanks for the contribution, @NielsRogge!

Another PR is addressing this on a different level so that it allows interaction through the CLI (#880), do you think you could take a look at it and provide feedback?

I will close this PR out in favor of that one so that we are all on the same page.