Table of Contents
Configure Your Hugging Face Access Token in Colab Environment
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.
Comment section
Hey, Adrian Rosebrock here, author and creator of PyImageSearch. While I love hearing from readers, a couple years ago I made the tough decision to no longer offer 1:1 help over blog post comments.
At the time I was receiving 200+ emails per day and another 100+ blog post comments. I simply did not have the time to moderate and respond to them all, and the sheer volume of requests was taking a toll on me.
Instead, my goal is to do the most good for the computer vision, deep learning, and OpenCV community at large by focusing my time on authoring high-quality blog posts, tutorials, and books/courses.
If you need help learning computer vision and deep learning, I suggest you refer to my full catalog of books and courses — they have helped tens of thousands of developers, students, and researchers just like yourself learn Computer Vision, Deep Learning, and OpenCV.
Click here to browse my full catalog.