系统信息
谷歌Colab,免费版,GPU
信息
- []官方示例脚本
- [X] 我自己修改的脚本
任务
- []
examples
文件夹中官方支持的任务(如GLUE/SQuAD,…( - [X] 我自己的任务或数据集(在下面提供详细信息(
复制
- https://github.com/woctezuma/stable-diffusion-colab
- https://colab.research.google.com/github/woctezuma/stable-diffusion-colab/blob/main/stable_diffusion.ipynb#scrollTo=GR4vF2bw-sHR
- 将创建复制到驱动器
- 运行第一个单元格
- 运行第二个单元格
- 从复制我的令牌https://huggingface.co/settings/tokens
- 粘贴到文件
- 按回车键
- #第一个错误-https://discuss.huggingface.co/t/invalid-token-passed/22711
- https://huggingface.co/settings/tokens管理失效和重构
- 再次运行第二个单元格
- 复制并粘贴到新令牌中
_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|
_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
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
- 我已经运行了
git config --global credential.helper store
,我可以重新运行所有内容并向前移动2个单元格 - 单元格代码
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)
- 错误
[/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)
预期行为
运行所有单元格并生成照片,如GitHub项目所示https://github.com/woctezuma/stable-diffusion-colab
只需访问huggingface网站并同意条款即可。
https://huggingface.co/CompVis/stable-diffusion-v1-4
你需要登录你的拥抱脸账户。