woctezuma / stable-diffusion-colab
Author: stromal
Pull request: no

### System Info

Google Colab, Free version, GPU

### Who can help?

@NielsRogge, @sgugger

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

1. https://github.com/woctezuma/stable-diffusion-colab
2. https://colab.research.google.com/github/woctezuma/stable-diffusion-colab/blob/main/stable_diffusion.ipynb#scrollTo=GR4vF2bw-sHR
3. copy create to drive
4. run 1st cell
5. run 2nd cell
6. copy my token from  https://huggingface.co/settings/tokens
7. paste it to the filed
8. press enter
9. #1st error - https://discuss.huggingface.co/t/invalid-token-passed/22711
10. https://huggingface.co/settings/tokens mange invalidate and refres
11. run 2nd cell again
12. copy and paste in new token 
```
        _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
        _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
        _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
        _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
        _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

        To login, `huggingface_hub` now requires a token generated from https://huggingface.co/settings/tokens .
        
Token: 
Login successful
Your token has been saved to /root/.huggingface/token
Authenticated through git-credential store but this isn't the helper defined on your machine.
You might have to re-authenticate when pushing to the Hugging Face Hub. Run the following command in your terminal in case you want to set this credential helper as the default

git config --global credential.helper store
```

13. I have run ```git config --global credential.helper store``` than I could  rerun everything and move forward 2 cells 
14. Cell CODE

```
import mediapy as media
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline

model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda"
remove_safety = False


pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16, revision="fp16", use_auth_token=True)
if remove_safety:
  pipe.safety_checker = lambda images, clip_input: (images, False)
pipe = pipe.to(device)
```
15. ERROR

```
[/usr/local/lib/python3.7/dist-packages/requests/models.py](https://localhost:8080/#) in raise_for_status(self)
    940         if http_error_msg:
--> 941             raise HTTPError(http_error_msg, response=self)
    942 

HTTPError: 403 Client Error: Forbidden for url: https://huggingface.co/CompVis/stable-diffusion-v1-4/resolve/fp16/model_index.json

The above exception was the direct cause of the following exception:

HfHubHTTPError                            Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/diffusers/configuration_utils.py](https://localhost:8080/#) in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
    233                     subfolder=subfolder,
--> 234                     revision=revision,
    235                 )

[/usr/local/lib/python3.7/dist-packages/huggingface_hub/file_download.py](https://localhost:8080/#) in hf_hub_download(repo_id, filename, subfolder, repo_type, revision, library_name, library_version, cache_dir, user_agent, force_download, force_filename, proxies, etag_timeout, resume_download, use_auth_token, local_files_only, legacy_cache_layout)
   1056                     proxies=proxies,
-> 1057                     timeout=etag_timeout,
   1058                 )

[/usr/local/lib/python3.7/dist-packages/huggingface_hub/file_download.py](https://localhost:8080/#) in get_hf_file_metadata(url, use_auth_token, proxies, timeout)
   1358     )
-> 1359     hf_raise_for_status(r)
   1360 

[/usr/local/lib/python3.7/dist-packages/huggingface_hub/utils/_errors.py](https://localhost:8080/#) in hf_raise_for_status(response, endpoint_name)
    253         # as well (request id and/or server error message)
--> 254         raise HfHubHTTPError(str(HTTPError), response=response) from e
    255 

HfHubHTTPError: <class 'requests.exceptions.HTTPError'> (Request ID: esduBFUm9KJXSxYhFffq4)

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
[<ipython-input-6-9b05f13f8bf3>](https://localhost:8080/#) in <module>
      9 
     10 
---> 11 pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float16, revision="fp16", use_auth_token=True)
     12 if remove_safety:
     13   pipe.safety_checker = lambda images, clip_input: (images, False)

[/usr/local/lib/python3.7/dist-packages/diffusers/pipeline_utils.py](https://localhost:8080/#) in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    371                 local_files_only=local_files_only,
    372                 use_auth_token=use_auth_token,
--> 373                 revision=revision,
    374             )
    375             # make sure we only download sub-folders and `diffusers` filenames

[/usr/local/lib/python3.7/dist-packages/diffusers/configuration_utils.py](https://localhost:8080/#) in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
    254             except HTTPError as err:
    255                 raise EnvironmentError(
--> 256                     "There was a specific connection error when trying to load"
    257                     f" {pretrained_model_name_or_path}:\n{err}"
    258                 )

OSError: There was a specific connection error when trying to load CompVis/stable-diffusion-v1-4:
<class 'requests.exceptions.HTTPError'> (Request ID: esduBFUm9KJXSxYhFffq4)
```


### Expected behavior

Run all the cells and generating photo's as on the GitHub project shows 
https://github.com/woctezuma/stable-diffusion-colab 

Comments:
The error is that your token is not properly registered or does not grant access to the model. If you have accepted the terms of the license online, then it's probably a bug in `huggingface_hub` not setting your token properly, so you should report an issue in that repo :-)

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.