Stable Diffusion / huggingface 相关配置问题汇总

Stable Diffusion / huggingface 相关配置问题汇总

    正在检查是否收录...

目录

1 `OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'.` 报错 解决方法 方法1——手动下载 方法2——自动下载 其他方法(待研究) 2 `huggingface_hub.utils._errors.LocalEntryNotFoundError:` 报错 解决方法


笔者在配置SD的时候遭遇了许多bug,特此汇总如下:

1 OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'.

报错

完整报错如下:

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. 

这是由于 huggingface 网站上不去导致的。

解决方法

方法1——手动下载

在本地新建文件夹 openai/clip-vit-large-patch14,将官网对应位置下面的文件全部下下来放进去即可123。
官方网址:https://huggingface.co/openai/clip-vit-large-patch14/tree/main
国内镜像:

https://www.modelscope.cn/models/AI-ModelScope/clip-vit-large-patch14/files https://hf-mirror.com/openai/clip-vit-large-patch14/tree/main

或者百度网盘:
链接: https://pan.baidu.com/s/1pmOuyaRnLcc8ee-8_jtb1g?pwd=ukyi 提取码: ukyi 复制这段内容后打开百度网盘手机App,操作更方便哦
–来自百度网盘超级会员v9的分享

方法2——自动下载

在本地新建文件夹 openai 之后,在该路径下利用 git clone https://www.modelscope.cn/AI-ModelScope/clip-vit-large-patch14.git 自动下载4,但是注意到此时会报错 safetensors_rust.SafetensorError,具体如下:

 File "/home/xxx/.conda/envs/xxx/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3503, in from_pretrained with safe_open(resolved_archive_file, framework="pt") as f: safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge 

原因是几个大一点文件没有完整下载,需要重新手动下载并覆盖。

其他方法(待研究)

在transformers/utils/hub.py的源码中,将’_default_endpoint’的值改为国内镜像https://hf-mirror.com即可5 (实测未成功) 安装依赖包 pip install -U huggingface_hub,然后修改HF_ENDPOINT 环境变量6 (未验证)
export HF_ENDPOINT=https://hf-mirror.com # Linux set HF_ENDPOINT=https://hf-mirror.com # Windows huggingface-cli download --resume-download InstantX/InstantID --local-dir checkpoints 

2 huggingface_hub.utils._errors.LocalEntryNotFoundError:

报错

出现如下报错:

 File "/home/xxx/.conda/envs/xxx/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1371, in hf_hub_download raise LocalEntryNotFoundError( huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on. 

还是网络的问题。

解决方法

参考博文:【秒解决!!huggingface_hub.utils._errors.LocalEntryNotFoundError】,将 huggingface 网站 改成其镜像站:

方法1:在代码开头设置环境变量
import os os.environ["HF_ENDPOINT"] = "https://hf-mirror.com" 
方法2:在命令行中设置环境变量 HF_ENDPOINT=https://hf-mirror.com python xxx.py

OSError: Can‘t load tokenizer for ‘openai/clip-vit-large-patch14‘. ↩︎

Stable-diffusion安装时Can‘t load tokenizer for ‘openai/clip-vit-large-patch14‘问题解决 ↩︎

【debug】OSError: Can‘t load tokenizer for ‘XXX‘. If you were trying to load it from ‘https://huggingf ↩︎

StableDiffusion搭建[报错] OSError openai/clip-vit-large-patch14 ↩︎

解决diffusion部署时,无法从‘huggingface.co‘下载‘openai/clip-vit-large-patch14‘导致的报错 ↩︎

Huggingface 镜像站使用方法! ↩︎

总结

本文总结了在使用Stable Diffusion时可能遇到的两个常见错误及其解决方法。
第一个问题是`OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'.`,这个错误通常是由于无法从`huggingface.co`下载所需模型导致的。文章提供了两种解决方法:手动下载模型文件并放置在正确的文件夹中,或者通过`git clone`命令自动下载,但可能需要手动修复未完整下载的大文件。此外,还提到了一些待研究的其他方法,如修改`transformers/utils/hub.py`中的默认下载源为国内镜像或设置环境变量来改变下载源。
第二个问题是`huggingface_hub.utils._errors.LocalEntryNotFoundError`,这是一个由于网络连接问题导致的错误。文章提供了两种解决方法:在代码开头设置环境变量`HF_ENDPOINT`为国内的镜像站地址,或者在命令行中设置该环境变量后运行Python脚本。
这些解决方法都旨在解决由于网络问题导致的模型下载失败问题,通过改用国内镜像站或手动下载模型文件来规避网络限制。 clihuggingfaceclipopenaitokenpythondiffusiontransformer百度网盘git文件夹transformersclonectoapp命令行instantidstablediffusionwindowslinux
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-17977.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

深入探索Stable Diffusion:从原理到应用的全面解析

上一篇

如何使用Whisper语音识别模型

下一篇
  • 复制图片
按住ctrl可打开默认菜单