Failed to download Model(Cannot access gated repo…)

This article can be read in about 5 minutes.
PR

The purpose 

You may encounter an error like the following when attempting to automatically download models using from_pretrained or similar methods, preventing the download.

Cannot access gated repo for url https://huggingface.co/ modelPath.
Access to model modelPath is restricted. You must have access to it and be authenticated to access it. Please log in.

Examples:

Cannot access gated repo for url https://huggingface.co/stabilityai/stable-audio-open-1.0/resolve/main/model_index.json.
Access to model stabilityai/stable-audio-open-1.0 is restricted. You must have access to it and be authenticated to access it. Please log in.

This article will introduce countermeasures for when the above error occurs.

PR

Solution

Delete everything after resolve in the URL where the error was displayed. Then, access the file you tried to download (for example, from https://huggingface.co/stabilityai/stable-audio-open-1.0/resolve/main/model_index.json, remove resolve/main/model_index.json to get https://huggingface.co/stabilityai/stable-audio-open-1.0/, then navigate to “Files and versions” and click model_index.json) and check if you can download it. (It’s sufficient to confirm that the download begins; you don’t need to complete it.)

If a 401/403 error is displayed and the download fails, please refer to the article below to resolve the issue and enable downloads.

In the case of a 404 error, it’s highly probable that your code is incorrect (i.e., the model path does not match the current one), so it would be best to check your source code.

Once you have confirmed that you can download it in a browser, access the following website:

Hugging Face – The AI community building the future.
We’re on a journey to advance and democratize artificial intelligence through open source and open science.

+ Create New token(ページ右上)をクリックします。

Click “+ Create New token” (top right of the page).

A token will be displayed (it is actually shown in the blacked-out area below). Click “Copy.”

Run the following command in the terminal (command prompt) where you execute your code.

huggingface-cli login

When “Enter your token (input will not be visible):” is displayed, right-click to paste the Token you copied above.

If you have copied other things like the command above, please copy the Token again.

The characters will not be displayed even if you right-click and paste. After right-clicking, simply press Enter.

When asked “Add token as git credential? (Y/n)”, enter n. After confirming that no error is displayed, re-run the script that previously failed to download.

PR

Result

That’s great news!

Here’s the translation:

We can download the model that previously failed to download with from_pretrained.

comment

Copied title and URL