Open 7enChan opened 2 months ago
I referenced this link and added the following code, replacing it with my own token as a temporary solution:
from huggingface_hub import login
login(token="your_access_token")
This allowed me to resolve the issue for now. I don't know much about coding, but I understand that using a personal access token directly in the code is not the correct long-term solution, as it is not very scalable or secure.
Hello,
The other way to pass the access token is through the huggingface cli. In your terminal, type
huggingface-cli login
This will ask for your HF Token, and you’ll be good to go after that. If you do not have the cli installed, follow the instructions here.
I am not fully sure what the cleanest/best way is to handle this in code at the moment (e.g maybe nothing should be added and authentication should purely be done outside this repo as I guess is the case for using huggingface-cli
?). For now, I'll simply link to this issue in the readme to point people in the right direction if they get any related troubles.
User have to create API token from Hugging Face with Repositories permissions to 'black-forest-labs/FLUX.1-dev' search for repos. Than do 'huggingface-cli login' in terminal with the token
User have to create API token from Hugging Face with Repositories permissions to 'black-forest-labs/FLUX.1-dev' search for repos. Than do 'huggingface-cli login' in terminal with the token
I am assuming you are referring to an .env file. Where do we place the token?
@sanctimon huggingface-cli login
invites you to paste in the token you got from HF, and the CLI will take care of putting the token where it should go.
Just trust huggingface-cli login
, this is the way.
You can also use env vars HF_TOKEN
and HUGGING_FACE_HUB_TOKEN
if you want to do this manually.
$ huggingface-cli login
_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Enter your token (input will not be visible):
Add token as git credential? (Y/n)
Token is valid (permission: write).
Your token has been saved in your configured git credential helpers (osxkeychain).
Your token has been saved to /Users/username/.cache/huggingface/token
Login successful
Thank you, that was really useful and I was able to run and activate. However, as I am running ComfyUI from within Pinokio, it still does not seem to recognise the token. I am sure I would need to install this in the venv that Pinokio is running ComfyUI in, but I cannot for the life of me find a way to access it.
@sanctimon in that case, you can bypass the attempt by Pinokio to download itself, and just ask huggingface-cli download
to pre-cache the model for you. Once it's pre-cached on the CLI, any GUI apps a layer above should just accept the cache without attempting to call HF from its code.
Try this in the terminal where you successfully logged in:
huggingface-cli download black-forest-labs/FLUX.1-dev
^ should work for any model you find on HF, for any tool that uses it, not specific to mflux or Pinokio.
Hi there, I'm trying to use the FLUX.1-dev model from the black-forest-labs repository on the Hugging Face Hub, but I'm encountering an issue where I'm unable to access the gated repository. When running the code, I'm getting the following error:
huggingface_hub.utils._errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-66c53d39-68d77c7933c60a4939ed6363;0a757519-549c-463e-9f18-356e8663f1f5) Cannot access gated repo for url https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/0ef5fff789c832c5c7f4e127f94c8b54bbcced44/tokenizer/merges.txt. Access to model black-forest-labs/FLUX.1-dev is restricted. You must be authenticated to access it.
I'm able to directly access the URL in my browser, but it seems that the code is unable to authenticate correctly when trying to download the files. I've double-checked my authentication credentials, but I'm still running into this issue. Could you please help me troubleshoot this problem? I'd be happy to provide any additional information or logs that might be helpful.