当前位置: 代码网 > 服务器>网络>网络协议 > 【debug】OSError: Can‘t load tokenizer for ‘XXX‘. If you were trying to load it from ‘https://huggingf

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

2024年08月02日 网络协议 我要评论
本地目录与 ‘openai/clip-vit-large-patch14’ 同名:如果你的本地目录中有一个名为 ‘openai/clip-vit-large-patch14’ 的文件夹,可能会导致加载错误。请检查你的工作目录或者其他相关目录中是否有同名文件夹,并确保没有命名冲突。模型路径错误:确保 ‘openai/clip-vit-large-patch14’ 是正确的模型路径,可以尝试重新确认模型路径是否正确。

diffusion模型遇到问题:缺少某个库,不能自动下载。

oserror: can't load tokenizer for 'xxxxxxxxx'. 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 'xxxxxxxxx' is the correct path to a directory containing all relevant files for a cliptokenizer tokenizer.

例如

  file "/home/spai/code/sd/stable-diffusion/ldm/util.py", line 85, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()))
  file "/home/spai/code/sd/stable-diffusion/ldm/modules/encoders/modules.py", line 141, in __init__
    self.tokenizer = cliptokenizer.from_pretrained(version)
  file "/home/spai/anaconda3/envs/metap/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1838, 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.

原因

提示显示无法加载该模型的分词器(tokenizer),可能出现了以下情况之一:

  1. 本地目录与 ‘openai/clip-vit-large-patch14’ 同名:如果你的本地目录中有一个名为 ‘openai/clip-vit-large-patch14’ 的文件夹,可能会导致加载错误。请检查你的工作目录或者其他相关目录中是否有同名文件夹,并确保没有命名冲突。

  2. 模型路径错误:确保 ‘openai/clip-vit-large-patch14’ 是正确的模型路径,可以尝试重新确认模型路径是否正确。

  3. 自动下载没找到,需要手动下载,放进去。可能是防火墙、urlib、ssl、服务器等问题

解决

手动下载模型

以上面的clip缺失为例:
在huggingface.co中搜索,找到相关库
从https://huggingface.co/openai/clip-vit-large-patch14/tree/main下载所有文件
在这里插入图片描述

 mkdir -p stable-diffusion-webui/openai/clip-vit-large-patch14

并将其移动到 本地目录/openai//clip-vit-large-patch14/

下载失败的话,看我的其他文章,用到 lfs 或者迅雷单独下载

修正网络

    import ssl
    ssl._create_default_https_context=ssl._create_unverified_context

为什么可以解决?

参考 https://blog.csdn.net/betrayfree/article/details/132482843

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com