Windows平台安装stable-diffusion-webui-1.7.0解决少工具包clip-vit-large-patch14

Windows 平台基于 stable-diffusion-webui-1.7.0进行部署。

遇到问题,先静下心来,找到关键词,定位分析错误日志。

个人心得,解决问题三步曲:

  1. 定位问题,比如部署 stable-diffusion-webui 遇到问题,定位关键词Failed(执行失败),OSError(错误)。
  2. 分析问题,缺少 openai/clip-vit-large-patch14 ,无法访问 https://huggingface.co/models 网址。
  3. 如果无法独立解决,可以借助搜索引擎(必应或者谷歌)或者 github issues 以及 Stack Overflow 解决问题。

部署 stable-diffusion-webui-1.7.0 过程中,解决缺少工具包openai/clip-vit-large-patch14 的问题,希望对你的工作或者学习有所帮助。

错误日志

运行.\webui.bat,进入控制台(Windows terminal)查看错误日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
PS E:\AI\stable-diffusion-webui-1.7.0> .\webui.bat
venv "E:\AI\stable-diffusion-webui-1.7.0\venv\Scripts\Python.exe"
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: 1.7.0
Commit hash: <none>
Launching Web UI with arguments:
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Style database not found: E:\AI\stable-diffusion-webui-1.7.0\styles.csv
Loading weights [e903d5679c] from E:\AI\stable-diffusion-webui-1.7.0\models\Stable-diffusion\hanfu_song_v31.safetensors
Creating model from config: E:\AI\stable-diffusion-webui-1.7.0\configs\v1-inference.yaml
Running on local URL: http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 20.8s (prepare environment: 5.5s, import torch: 6.0s, import gradio: 1.7s, setup paths: 2.4s, initialize shared: 0.3s, other imports: 1.0s, setup codeformer: 0.2s, load scripts: 2.0s, create ui: 0.8s, gradio launch: 0.8s).
creating model quickly: OSError
Traceback (most recent call last):
File "D:\software\Python310\lib\threading.py", line 973, in _bootstrap
self._bootstrap_inner()
File "D:\software\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "D:\software\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "E:\AI\stable-diffusion-webui-1.7.0\modules\initialize.py", line 147, in load_model
shared.sd_model # noqa: B018
File "E:\AI\stable-diffusion-webui-1.7.0\modules\shared_items.py", line 128, in sd_model
return modules.sd_models.model_data.get_sd_model()
File "E:\AI\stable-diffusion-webui-1.7.0\modules\sd_models.py", line 531, in get_sd_model
load_model()
File "E:\AI\stable-diffusion-webui-1.7.0\modules\sd_models.py", line 634, in load_model
sd_model = instantiate_from_config(sd_config.model)
File "E:\AI\stable-diffusion-webui-1.7.0\repositories\stable-diffusion-stability-ai\ldm\util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "E:\AI\stable-diffusion-webui-1.7.0\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 563, in __init__
self.instantiate_cond_stage(cond_stage_config)
File "E:\AI\stable-diffusion-webui-1.7.0\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 630, in instantiate_cond_stage
model = instantiate_from_config(config)
File "E:\AI\stable-diffusion-webui-1.7.0\repositories\stable-diffusion-stability-ai\ldm\util.py", line 89, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "E:\AI\stable-diffusion-webui-1.7.0\repositories\stable-diffusion-stability-ai\ldm\modules\encoders\modules.py", line 103, in __init__
self.tokenizer = CLIPTokenizer.from_pretrained(version)
File "E:\AI\stable-diffusion-webui-1.7.0\venv\lib\site-packages\transformers\tokenization_utils_base.py", line 1809, in from_pretrained
raise EnvironmentError(
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

Failed to create model quickly; will retry using slow method.
Stable diffusion model failed to load

遇到问题不要害怕,或者说怕麻烦,就直接利用搜索引擎或者相关论坛。

个人心得,解决问题三步曲:

  1. 定位问题,比如部署 stable-diffusion-webui 遇到问题,定位关键词Failed(执行失败),OSError(错误)。
  2. 分析问题,缺少 openai/clip-vit-large-patch14 ,无法访问 https://huggingface.co/models 网址。
  3. 如果无法独立解决,可以借助搜索引擎(必应或者谷歌)或者 github issues 以及 Stack Overflow 解决问题。

分析日志,划重点,缺少工具包openai/clip-vit-large-patch14

1
2
3
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

Stable diffusion model failed to load

友情提醒:由于网络原因,无法访问 https://huggingface.co/models ,可以通过国内镜像站获取资源。

解决方案

进入解压后的 stable-diffusion-webui-1.7.0 目录,创建目录 openai。

1
2
3
4
5
6
7
PS E:\AI\stable-diffusion-webui-1.7.0> mkdir openai

Directory: E:\AI\stable-diffusion-webui-1.7.0

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2024-2-1 12:15 openai

进入目录 openai

1
PS E:\AI\stable-diffusion-webui-1.7.0> cd .\openai\

通过魔搭社区镜像站获取 clip-vit-large-patch14,使用 git 获取,默认你已经部署并配置好 Git 环境,当然你还可以参考魔搭社区提供的参考文档

1
2
3
4
5
6
7
8
9
10
PS E:\AI\stable-diffusion-webui-1.7.0\openai> git clone https://www.modelscope.cn/AI-ModelScope/clip-vit-large-patch14.git
Cloning into 'clip-vit-large-patch14'...
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 22 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (22/22), 1.08 MiB | 2.22 MiB/s, done.
Resolving deltas: 100% (1/1), done.
Updating files: 100% (14/14), done.
Filtering content: 100% (4/4), 6.37 GiB | 9.66 MiB/s, done.

啊,你没有看错,你的 Git 并没有卡住。

下载完大约有 12.7GB 左右,所需时间可能有点长,这个还取决于你的下载网速和对方服务器所能提供的带宽速率。

——END——