复现项目(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 问题
- 在python代码中加入
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
- 在命令行中设置环境变量
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’
- 在 vs code 中搜索 models/image_encoder,结果发现当前终端所在的路径不对(不是在 ./path/to/InstantStyle 里)。
- 为避免类似问题,将所有模型的路径修改为绝对路径后报错解决!

1760

被折叠的 条评论
为什么被折叠?



