The Hub is a central platform where anyone can share and explore models, datasets, and ML demos. It aims to build the most extensive collection of Open Source models, datasets, and demos.
Sharing to the Hub could amplify the impact of a fastai Learner by making it available for others to download and explore.
Anyone can access all the fastai models in the Hub by filtering the huggingface.co/models webpage by the fastai library, as in the image below.
To know more about the Hub, refer to this introduction.
huggingface_hub. Additionally, the integration functions require the following packages:
You can install these packages manually or specify
["fastai"] when installing
huggingface_hub, and your environment will be ready:
pip install huggingface_hub["fastai"]
Note: As of May 5, 2022, there has not been a release that includes the fastai+hub features so that you can install from
!pip install git+https://github.com/huggingface/huggingface_hub#egg=huggingface-hub["fastai"]
To share models in the Hub, you will need to have a user. Create it on the Hugging Face website.
There are three options to login to the Hugging Face Hub; your token will be available in your Account Settings:
huggingface-cli loginin your terminal and enter your token.
If in a python notebook, you can use
from huggingface_hub import notebook_login notebook_login()
- Use the
tokenargument of the
push_to_hub_fastai (refer to the Hub Client documentation) with the Learner you want to upload and the repository id for the Hub in the format of "namespace/repo_name". The namespace can be an individual account or an organization you have write access to (for example, 'fastai/stanza-de'). For more details, refer to the Hub Client documentation.
from huggingface_hub import push_to_hub_fastai push_to_hub_fastai(learner=learn, repo_id="espejelomar/cool_learner")
The Learner is now in the Hub with the id
When uploading a fastai Learner (or any other model) to the Hub, it is helpful to edit its model card (image below) so that others better understand your work (refer to the Hugging Face documentation).
To load a model in the Hub with the id
from huggingface_hub import from_pretrained_fastai learner = from_pretrained_fastai("ITESM/fastai_model")
The Hub Client documentation includes addtional details on