DEV Community

0xkoji
0xkoji

Posted on

HuggingFace login on Google Colab

Step1. Create a secret in Secrets

First, create a new secret. In this case, we will use HF_TOKEN but you can name whatever you want.

Colab Secrets

Step2. Load a secret and log in to Hugging Face

from huggingface_hub import login
from google.colab import userdata
HF_TOKEN=userdata.get('HF_TOKEN')

if HF_TOKEN:
    login(HF_TOKEN)
    print("Successfully logged in to Hugging Face!")
else:
    print("Token is not set. Please save the token first.")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)