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.