【StableDiffusion·秋叶4.8】ADetailer: Failed to load model ‘yolov8x-worldv2.pt‘ from huggingface 报错

一、问题描述

1.一键启动控制台报错 ADetailer: Failed to load model ‘yolov8x-worldv2.pt’ from huggingface…

完整报错内容:

'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /Bingsu/yolo-world-mirror/resolve/main/yolov8x-worldv2.pt (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002079874DFC0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/Bingsu/yolo-world-mirror/resolve/main/yolov8x-worldv2.pt
WARNING:huggingface_hub.utils._http:'HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /Bingsu/yolo-world-mirror/resolve/main/yolov8x-worldv2.pt (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002079874DFC0>, 'Connection to huggingface.co timed out. (connect timeout=10)'))' thrown while requesting HEAD https://huggingface.co/Bingsu/yolo-world-mirror/resolve/main/yolov8x-worldv2.pt
[-] ADetailer: Failed to load model 'yolov8x-worldv2.pt' from huggingface
[-] ADetailer initialized. version: 24.4.2, num models: 9
2.问题原因

在源代码中,引用 yolo 相关文件的时候,大部分都采用了从云端下载的方法,但是,huggingface已经被墙了
所以说,下载不到很正常。

二、解决方法

1.拿到 yolov8x-worldv2.pt 文件

你得会魔法,但是不是人人都会魔法,所以,我开了个下载链接:
链接:https://pan.baidu.com/s/12M0R4nB1gZ6ZC5A5H4VjDQ?pwd=9ydw
提取码:9ydw

2.修改源代码

2.1
把 yolov8x-worldv2.pt 文件找个合适的目录扔进去
我把它扔在 model 目录下面(请务必记住这个目录):

S:\app_AI\stableDiffusion-webui-aki\sd-webui-aki-v4.8\models\yolo_world_mirror

在这里插入图片描述

2.2
找到这个路径 (请参考我下面的路径,找到你自己的 common.py 文件!)

S:\app_AI\stableDiffusion-webui-aki\sd-webui-aki-v4.8\extensions\adetailer\adetailer\common.py

2.3
使用 IDE 打开 common.py 文件,找到下面的代码:
注释掉这个 get_models() 函数(主要是怕改崩溃了,留个备份)

在这里插入图片描述

2.4
重写一个新的 get_models() 函数
请一定要注意,在下面这个 get_models 函数中,这一行:
local_model_dir = “S:/app_AI/stableDiffusion-webui-aki/sd-webui-aki-v4.8/models/yolo_world_mirror”
!!!请把上面这个 local_model_dir 的路径,换成你刚才把 yolov8x-worldv2.pt 文件扔在的那个文件夹!!!我写的是我的路径,你要写你的路径

def get_models(
    *dirs: str | os.PathLike[str], huggingface: bool = True
) -> OrderedDict[str, str]:
    model_paths = []

    for dir_ in dirs:
        if not dir_:
            continue
        model_paths.extend(scan_model_dir(Path(dir_)))

    models = OrderedDict()

    def get_model_file(file: str, local_dir: str) -> str:
        local_file_path = os.path.join(local_dir, file)
        if os.path.exists(local_file_path):
            print(f"Using local model file: {local_file_path}")
            return local_file_path
        else:
            return hf_download(file)

    if huggingface:
        local_model_dir = "S:/app_AI/stableDiffusion-webui-aki/sd-webui-aki-v4.8/models/yolo_world_mirror"
        models.update(
            {
                "face_yolov8n.pt": hf_download("face_yolov8n.pt"),
                "face_yolov8s.pt": hf_download("face_yolov8s.pt"),
                "hand_yolov8n.pt": hf_download("hand_yolov8n.pt"),
                "person_yolov8n-seg.pt": hf_download("person_yolov8n-seg.pt"),
                "person_yolov8s-seg.pt": hf_download("person_yolov8s-seg.pt"),
                "yolov8x-worldv2.pt": get_model_file("yolov8x-worldv2.pt", local_model_dir),
            }
        )
    models.update(
        {
            "mediapipe_face_full": "mediapipe_face_full",
            "mediapipe_face_short": "mediapipe_face_short",
            "mediapipe_face_mesh": "mediapipe_face_mesh",
            "mediapipe_face_mesh_eyes_only": "mediapipe_face_mesh_eyes_only",
        }
    )

    invalid_keys = [k for k, v in models.items() if v == "INVALID"]
    for key in invalid_keys:
        models.pop(key)

    for path in model_paths:
        if path.name in models:
            continue
        models[path.name] = str(path)

    return models

三、解决啦

1.本地加载,报错没了

在这里插入图片描述

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MicroLindb

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值