【Diffusers 报错解决】401 Client Error, 404 Client Error, OSError: models/image_encoder is not a local

72 篇文章 16 订阅
37 篇文章 0 订阅

复现项目(https://github.com/InstantStyle/InstantStyle) 过程中遇到了以下报错

huggingface_hub.utils._errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-661e34c2-5000766c42fd1bf64d2626ee;f27da0da-dad3-4339-9cbf-07e16abddde7)

Repository Not Found for url: https://huggingface.co/models/image_encoder/resolve/main/config.json.
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated.
Invalid username or password.

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/path/to/InstantStyle/infer_style_plus.py", line 26, in <module>
    ip_model = IPAdapterPlusXL(pipe, image_encoder_path, ip_ckpt, device, num_tokens=16, target_blocks=["up_blocks.0.attentions.1"])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/InstantStyle/ip_adapter/ip_adapter.py", line 78, in __init__
    self.image_encoder = CLIPVisionModelWithProjection.from_pretrained(self.image_encoder_path, use_auth_token='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').to(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/miniconda3/envs/InstantStyle/lib/python3.12/site-packages/transformers/modeling_utils.py", line 2899, in from_pretrained
    resolved_config_file = cached_file(
                           ^^^^^^^^^^^^
  File "/path/to/miniconda3/envs/InstantStyle/lib/python3.12/site-packages/transformers/utils/hub.py", line 421, in cached_file
    raise EnvironmentError(
OSError: models/image_encoder is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`

解决 401 Client Error 问题

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

参考:https://discuss.huggingface.co/t/error-401-client-error-unauthorized-for-url/19714 和 https://blog.csdn.net/weixin_44257107/article/details/136532423

结果并发现不适用

解决 OSError

OSError报错提到: models/image_encoder is not a local folder and is not a valid model identifier listed on ‘https://huggingface.co/models’

  1. 在 vs code 中搜索 models/image_encoder,结果发现当前终端所在的路径不对(不是在 ./path/to/InstantStyle 里)。
  2. 为避免类似问题,将所有模型的路径修改为绝对路径后报错解决!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值