DEV Community

0xkoji
0xkoji

Posted on

3

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay