continue-revolution/sd-webui-segment-anything

Internet problem with downloading Models/网络问题无法使用groundingDINO,下载本地模型后依然无法使用

Fatal-Eror opened this issue · 22 comments

我使用的是windows的秋叶整合包v4.2
我之前做的操作:
1.根据这个视频内容,https://www.bilibili.com/video/BV1Vh411F7Zn/?spm_id_from=333.337.search-card.all.click&vd_source=5fdf8441f38454739cb347f940e766c2 ,先是尝试了不勾选bypass c++ problem的配置,配置完成后点击generate bounding box,会显示time out或者远程主机关闭了链接之类的问题, 在https://huggingface.co/ShilongLiu/GroundingDINO/tree/main 下载两个模型并放置在models\grounding-dino后仍然还是提示网络问题的报错。我的网络也确实可以正常访问抱脸和github。
2.尝试勾选bypass c++problem,并且留了两个模型在文件夹内,点击generate仍然还是会显示同样的报错信息。偶尔有时不报错并开始下载,但下载速度非常慢只有几十k。
目前不太清楚是为什么连接有问题,以及想问下为什么没有直接使用我手动下载的模型开始生成。

I have tried to use this extention with no ticking bypass c++ problem and the ticking one, but i met some problem with downloading the GroundingDINO models from huggingface like the following error info. Even if i tried to manually download the models from "https://huggingface.co/ShilongLiu/GroundingDINO/tree/main", and ticked the bypass c++ problem option, it still could not work.
I dont know why this internet problem happen, and why it still cannot work with downloaded models.

以下是显示远程主机断开连接的报错信息/ This is the error info:

Running GroundingDINO Inference
Initializing GroundingDINO GroundingDINO_SwinT_OGC (694MB)
final text_encoder_type: bert-base-uncased
Traceback (most recent call last):
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 1071, in _create
    self.do_handshake()
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。
提示:Python 运行时抛出了一个异常。请检查疑难解答页面。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\util\retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\connection.py", line 419, in connect
    self.sock = ssl_wrap_socket(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 1071, in _create
    self.do_handshake()
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\gradio\routes.py", line 422, in run_predict
    output = await app.get_blocks().process_api(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\gradio\blocks.py", line 1323, in process_api
    result = await self.call_function(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\gradio\blocks.py", line 1051, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\scripts\sam.py", line 247, in dino_predict
    boxes_filt, install_success = dino_predict_internal(input_image, dino_model_name, text_prompt, box_threshold)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\scripts\dino.py", line 173, in dino_predict_internal
    dino_model = load_dino_model(dino_model_name, install_success)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\scripts\dino.py", line 119, in load_dino_model
    dino = build_model(args)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\local_groundingdino\models\__init__.py", line 17, in build_model
    model = build_func(args)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\local_groundingdino\models\GroundingDINO\groundingdino.py", line 362, in build_groundingdino
    model = GroundingDINO(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\local_groundingdino\models\GroundingDINO\groundingdino.py", line 98, in __init__
    self.bert = get_tokenlizer.get_pretrained_language_model(text_encoder_type)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\local_groundingdino\util\get_tokenlizer.py", line 25, in get_pretrained_language_model
    return BertModel.from_pretrained(text_encoder_type)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\transformers\modeling_utils.py", line 2137, in from_pretrained
    resolved_archive_file = cached_file(pretrained_model_name_or_path, filename, **cached_file_kwargs)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\transformers\utils\hub.py", line 409, in cached_file
    resolved_file = hf_hub_download(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\huggingface_hub\utils\_validators.py", line 120, in _inner_fn
    return fn(*args, **kwargs)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\huggingface_hub\file_download.py", line 1364, in hf_hub_download
    http_get(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\huggingface_hub\file_download.py", line 505, in http_get
    r = _request_wrapper(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\huggingface_hub\file_download.py", line 442, in _request_wrapper
    return http_backoff(
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\huggingface_hub\utils\_http.py", line 212, in http_backoff
    response = session.request(method=method, url=url, **kwargs)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "D:\Life\WebUI\sd-webui-aki-v4.2\python\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))

huggingface被墙了,你终端没办法下载Bert的tokenizer

终端代理有它自己的配法

huggingface被墙了,你终端没办法下载Bert的tokenizer

终端代理有它自己的配法

那自己手动下载的两个模型文件要怎么样才能让他用上呢,直接塞到插件的model里他好像没检测到,还是会去抱脸继续下载

位置放错了可能

位置放错了可能

我放的位置是sd-webui-aki-v4.2\extensions\sd-webui-segment-anything\models\grounding-dino,应该是和他说的位置一样吧,或是说除了两个py和两个pth还需要其他文件吗

你下载的groundingdino模型并不是bert的tokenizer,tokenizer是另外的东西,是用来识别你文字的东西。

这个tokenizer目前只能通过终端自动下载,你需要配置终端代理,即http_proxy和https_proxy。因为huggingface代码库诡异的下载逻辑,我尚不知道如何直接下载然后放到某个文件夹。可能会在下下一个版本再尝试解决这个问题。

你下载的groundingdino模型并不是bert的tokenizer,tokenizer是另外的东西,是用来识别你文字的东西。

这个tokenizer目前只能通过终端自动下载,你需要配置终端代理,即http_proxy和https_proxy。因为huggingface代码库诡异的下载逻辑,我尚不知道如何直接下载然后放到某个文件夹。可能会在下下一个版本再尝试解决这个问题。

感谢大佬指路,目前问题已经解决,确实就是终端代理不行。解决方法是:

  1. 开启clash梯子
  2. windows自己的设置-网络和internet-代理,关闭自动检测设置,手动代理设置-使用代理服务器设置为开,并复制代理ip和端口号,例如我这里是http://127.0.0.1:7890 (不同人最后四位可能不一样)
  3. 随便谷歌一下确定浏览器是能翻墙出去的
  4. 秋叶包左边最底下的设置-一般设置-网络设置-代理设置-代理服务器地址填上上面的ip,我这里是http://127.0.0.1:7890 ,把下面所有将代理应用到xxx全部开启。如果你不是使用秋叶包,而是用其他脚本或自己配置的终端,可以参考这个链接里的终端代理设置,里面有提及如何配置cmd,git和powershell的终端代理:https://sleepyocean.github.io/pages/da27da/
  5. 重新打开webui,点击generate bounding box成功开始下载两个模型,并识别内容

插件效果很棒,尝试识别人头和衣服之类的都非常不错,衷心感谢大佬的制作。

Have solved problem, the error is caused by terminal proxy.

  1. use clash
  2. windows settings-Network & internet-proxy, close auto setting, and use proxy server. Then i copy down the ip and port http://127.0.0.1:7890 (the last four digits might be different for different people).
  3. set terminal proxy, my webui launcher has a place to fill in the proxy configuration, and i copy http://127.0.0.1:7890 into it. If your launcher is different from mine, you can try to fix this internet problem with other terminal proxy tutorial, here is one teaching how to config the cmd, git, and powershell, https://sleepyocean.github.io/pages/da27da/ , the content is chinese but i think it can be translated by browser.
  4. open webui, click "generate bounding box", the terminal successfully download model from huggingface.

Note to English speakers: the above method only works for people who

  1. are using package from Akegarasu
  2. are blocked from accessing huggingface due to whatever reason.

This issue will be closed once I find a way to completely bypass downloading huggingface material from terminal.

你下载的groundingdino模型并不是bert的tokenizer,tokenizer是另外的东西,是用来识别你文字的东西。

这个tokenizer目前只能通过终端自动下载,你需要配置终端代理,即http_proxy和https_proxy。因为huggingface代码库诡异的下载逻辑,我尚不知道如何直接下载然后放到某个文件夹。可能会在下下一个版本再尝试解决这个问题。

那完蛋了 我用的国内云服务器,是墙不出来的。它一定要连到huggingface下载吗,我把上面这位成功的groundingdino文件夹复制过来用行不行

@openwaterer 有的云服务器提供学术加速服务,例如autodl,建议优先使用提供学术加速服务的云服务器。他会把bert下载到你不知道的位置,复制他的文件夹无法解决问题。

@openwaterer 有的云服务器提供学术加速服务,例如autodl,建议优先使用提供学术加速服务的云服务器。他会把bert下载到你不知道的位置,复制他的文件夹无法解决问题。

老哥 那我准备整个海外服务器,安装好后整个服务器文件镜像回国内服务器,这样可行吗。它总不会甚至都不在WebUI文件夹里面吧

@openwaterer 极有可能不在webui文件夹,它会在你的HF_HOME这个环境变量指向的文件夹里,如果HF_HOME为空,就会下载到~/.cache/hub (或者是类似的地方)

@openwaterer 极有可能不在webui文件夹,它会在你的HF_HOME这个环境变量指向的文件夹里,如果HF_HOME为空,就会下载到~/.cache/hub (或者是类似的地方)

好吧那我试试镜像整个服务器回来 感谢

没用整合包的怎么解决啊

没用整合包的怎么解决啊

你可以参考这个链接里的终端代理设置,里面有提及如何配置cmd,git和powershell的终端代理:https://sleepyocean.github.io/pages/da27da/

zyjssf commented

你下载的接地恐龙模型不是伯特的分词器,分词器是另外的东西,是用来识别你文字的东西。
tokenizer目前只能通过终端自动下载这个,你需要配置终端代理,即http_proxy和https_proxy。因为huggingface代码库诡异的下载逻辑,我尚异不知道如何直接下载然后放到某个文件夹。可能会在下下一个版本再尝试解决这个问题。

那完了我用国内的云服务器,是墙不出来的。它一定要连到huggingface下载吗,我把上面这个成功的groundingdino文件夹复制过来用行不行

现在遇到和你一样的问题了,直接复制文件进去没用,云服务器又不能翻墙,请问下这个问题解决了吗?

你下载的接地恐龙模型不是伯特的分词器,分词器是另外的东西,是用来识别你文字的东西。
tokenizer目前只能通过终端自动下载这个,你需要配置终端代理,即http_proxy和https_proxy。因为huggingface代码库诡异的下载逻辑,我尚异不知道如何直接下载然后放到某个文件夹。可能会在下下一个版本再尝试解决这个问题。

那完了我用国内的云服务器,是墙不出来的。它一定要连到huggingface下载吗,我把上面这个成功的groundingdino文件夹复制过来用行不行

现在遇到和你一样的问题了,直接复制文件进去没用,云服务器又不能翻墙,请问下这个问题解决了吗?

复制过来是可以用的, models--bert-base-uncased文件夹放在~/.cache/huggingface/hub下

I have solved this problem.
You need to start from https://huggingface.co/bert-base-uncased/tree/main Download files to stable differentiation-webui/bert-base-uncased (create this folder if it does not exist)

luchec commented

我更惨,用的是秋叶4.4的,setment anything装了,groundingdino的pth下载了,也放到\models\grounding-dino\下了,然后那个huggingface的文件也自动下好了在\sd-webui-aki-v4.4.cache\sdwebuilauncher\hfmirror\blob\ 里,结果一点预览,就直接爆错了。
完全无解

Using local groundingdino.
Running GroundingDINO Inference
Initializing GroundingDINO GroundingDINO_SwinT_OGC (694MB)
final text_encoder_type: bert-base-uncased
Traceback (most recent call last):
File "D:\StableDiffusion\sd-webui-aki-v4.4\python\lib\site-packages\transformers\modeling_utils.py", line 463, in load_state_dict
return torch.load(checkpoint_file, map_location="cpu")
File "D:\StableDiffusion\sd-webui-aki-v4.4\modules\safe.py", line 108, in load
return load_with_extra(filename, *args, extra_handler=global_extra_handler, **kwargs)
File "D:\StableDiffusion\sd-webui-aki-v4.4\modules\safe.py", line 156, in load_with_extra
return unsafe_torch_load(filename, *args, **kwargs)
File "D:\StableDiffusion\sd-webui-aki-v4.4\python\lib\site-packages\torch\serialization.py", line 815, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "D:\StableDiffusion\sd-webui-aki-v4.4\python\lib\site-packages\torch\serialization.py", line 1033, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\xf0'.

During handling of the above exception, another exception occurred:

。。。。。。

from a TF 2.0 checkpoint, please set from_tf=True.
提示:Python 运行时抛出了一个异常。请检查疑难解答页面。

@Fatal-Eror 十分感谢大佬,相同的问题按照大佬的操作顺利解决了!!!
Thank you very much!!!

Done. However, GroundingDINO installment has failed. Your process automatically fall back to local groundingdino. See your terminal for more detail and permanently switch to local groundingdino on Settings/Segment Anything or submit an issue to https://github.com/IDEA-Research/Grounded-Segment-Anything/issues.
如上报错,虽然改设置之后能从终端直接下groundingDino,但是下完后还是有这样的报错,我高兴早了 @Fatal-Eror