Configure Your Hugging Face Access Token in Colab Environment : Piyush Thakur

Configure Your Hugging Face Access Token in Colab Environment
by: Piyush Thakur
blow post content copied from  PyImageSearch
click here to view original post


Follow these steps to access Hugging Face resources in Colab.

Set Up Your Hugging Face Access Token

To set up the Access Token, go to https://huggingface.co/settings/tokens.

On this page, click on “+ Create new token”.

This will let you create a new access token. Here, switch to the “Write” tab. This token has read and write access to all of yours and your orgs resources and can make calls to Inference Providers on your behalf. Enter the Token Name as “HF_TOKEN” and hit the “Create token” button.

This opens a pop-up to save your created access token value somewhere safe. Click on “Copy” to copy the access token and paste it into your desired safe location. Click on “Done” to complete the access token generation process. Be sure to copy and save the token because once you hit “Done”, the pop-up will be closed, and you will not be able to copy and use the token value. You will need to recreate the token again.

This completes the access token generation process in Hugging Face.

Set Up Your Colab Secrets to Access Hugging Face Resources

On the left side of the Colab, click on the “key” symbol. This opens up a “Secrets” navigation menu.

Now, click on “+ Add new secret” to configure your Colab to access Hugging Face resources.

Here, toggle the “Notebook access” on. Enter the name “HF_TOKEN,” the same as what you created for the Hugging Face access token. Enter the Hugging Face access token value that you copied and saved earlier.

With this, you can access the Hugging Face resources in your Colab environment.

Grant Permission to Access Hugging Face Models like PaliGemma

Now, we can access Hugging Face resources, but to access the PaliGemma Model on Hugging Face, you are required to review and agree to Google’s usage license. Click on “Acknowledge license” to accept it.

This takes us to authorize through the Model License Consent using Kaggle. If you don’t have a kaggle account yet, create one. Click on “Authorize” here.

This opens up a “Gemma Access Request” page where you can enter your “First Name” and “Last Name”. The “Verified email” will already be filled with the email address that you used to log in to kaggle. Below will be the “Gemma Terms of Use”.

You can read and scroll down to tick the checkbox “I accept the terms and conditions (Required).” At last, click on “Accept” to accept it.

Now, you can see that you have been granted access to the PaliGemma model in Hugging Face.

NOTE: Colab could take some time to recognize the access. But eventually, you will get it, and you will be good to go.

Finally, you have your configuration environment set up to access the Hugging Face resources.

The post Configure Your Hugging Face Access Token in Colab Environment appeared first on PyImageSearch.


April 05, 2025 at 12:15AM
Click here for more details...

=============================
The original post is available in PyImageSearch by Piyush Thakur
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce