Logging in to Hugging Face
You may use the login()
function in the huggingface_hub
library like this:
from huggingface_hub import login login()
In doing so, you are authenticating with the Hugging Face Hub. This allows you to download pre-trained diffusion models that are hosted on the Hub. Without logging in, you may not be able to download these models using the model ID, such as runwayml/stable-diffusion-v1-5
.
When you run the preceding code, you are providing your Hugging Face token. You may wonder about the steps to access the token, but don’t worry. The token input dialog will provide links and information to access the token.
After you have logged in, you can download pre-trained diffusion models by using the from_pretrained()
function in the Diffusers package. For example, the following code will download the stable-diffusion-v1-5
model from the Hugging Face Hub:
import torch from diffusers import StableDiffusionPipeline text2img_pipe = StableDiffusionPipeline...