Push files to the Hub
Push files to the Hub
🌍 Diffusers provides a PushToHubMixin for uploading your model, scheduler, or pipeline to the Hub. It is an easy way to store your files on the Hub, and also allows you to share your work with others. Under the hood, the PushToHubMixin:
creates a repository on the Hub
saves your model, scheduler, or pipeline files so they can be reloaded later
uploads folder containing these files to the Hub
This guide will show you how to use the PushToHubMixin to upload your files to the Hub.
You’ll need to log in to your Hub account with your access token first:
Copied
Models
To push a model to the Hub, call push_to_hub() and specfiy the repository id of the model to be stored on the Hub:
Copied
For model’s, you can also specify the variant of the weights to push to the Hub. For example, to push fp16
weights:
Copied
The push_to_hub() function saves the model’s config.json
file and the weights are automatically saved in the safetensors
format.
Now you can reload the model from your repository on the Hub:
Copied
Scheduler
To push a scheduler to the Hub, call push_to_hub() and specfiy the repository id of the scheduler to be stored on the Hub:
Copied
The push_to_hub() function saves the scheduler’s scheduler_config.json
file to the specified repository.
Now you can reload the scheduler from your repository on the Hub:
Copied
Pipeline
You can also push an entire pipeline with all it’s components to the Hub. For example, initialize the components of a StableDiffusionPipeline with the parameters you want:
Copied
Pass all of the components to the StableDiffusionPipeline and call push_to_hub() to push the pipeline to the Hub:
Copied
The push_to_hub() function saves each component to a subfolder in the repository. Now you can reload the pipeline from your repository on the Hub:
Copied
Privacy
Set private=True
in the push_to_hub() function to keep your model, scheduler, or pipeline files private:
Copied
Private repositories are only visible to you, and other users won’t be able to clone the repository and your repository won’t appear in search results. Even if a user has the URL to your private repository, they’ll receive a 404 - Repo not found error.
To load a model, scheduler, or pipeline from a private or gated repositories, set use_auth_token=True
:
Copied
Last updated