使用代理时Stable Diffusion无法正常下载各类模型的解决办法

news/2024/11/13 16:18:07/

最近发现了 Stable Diffusion 这个好玩的ai绘画工具,不得不感叹现在ai工具已经进化到这么简单易用的程度,只要下载对应的模型就可以生成各种有意思的图片

就算你没有编程基础,跟着教程也能弄出来

不过使用过程中发现部分功能无法使用
查看日志发现是一些图片生成过程中需要的模型无法下载
在终端export代理地址之后,发现依旧报错

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

这个报错信息可以看出来就是Python无法验证SSL证书而引起的,搜索之后发现解决方法就是执行如下代码关闭ssl证书的认证

# 导入对应库
import ssl
# 全局关闭ssl验证
ssl._create_default_https_context = ssl._create_unverified_context

跟随 Stable Diffusion 的日志查看到第一个加载的python文件为 lanuch.py ,就位于 stable-diffusion-webui 根目录下,直接在文件顶部加就可以了
在这里插入图片描述

注意保存为utf-8格式 , 否则报错

之后重启 stable-diffusion-webui,再次使用相同功能生成图片,模型下载成功
在这里插入图片描述

完整报错如下,便于大家检索:”

Downloading: "https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth" to <你的安装路径>/stable-diffusion-webui/models/GFPGAN/detection_Resnet50_Final.pthError completing requestArguments: (0, <PIL.Image.Image image mode=RGB size=512x512 at 0x2BA2524D0>, None, '', '', True, 0, 4, 512, 512, True, 'Lanczos', 'R-ESRGAN 4x+', 0, 0.116, 0.183, 0.214) {}
Traceback (most recent call last):File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1348, in do_openh.request(req.get_method(), req.selector, req.data, headers,File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in requestself._send_request(method, url, body, headers, encode_chunked)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_requestself.endheaders(body, encode_chunked=encode_chunked)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheadersself._send_output(message_body, encode_chunked=encode_chunked)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1037, in _send_outputself.send(msg)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 975, in sendself.connect()File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1454, in connectself.sock = self._context.wrap_socket(self.sock,File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 513, in wrap_socketreturn self.sslsocket_class._create(File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1071, in _createself.do_handshake()File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1342, in do_handshakeself._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)During handling of the above exception, another exception occurred:Traceback (most recent call last):File "<你的安装路径>/stable-diffusion-webui/modules/call_queue.py", line 56, in fres = list(func(*args, **kwargs))File "<你的安装路径>/stable-diffusion-webui/modules/call_queue.py", line 37, in fres = func(*args, **kwargs)File "<你的安装路径>/stable-diffusion-webui/modules/postprocessing.py", line 56, in run_postprocessingscripts.scripts_postproc.run(pp, args)File "<你的安装路径>/stable-diffusion-webui/modules/scripts_postprocessing.py", line 130, in runscript.process(pp, **process_args)File "<你的安装路径>/stable-diffusion-webui/scripts/postprocessing_gfpgan.py", line 26, in processrestored_img = gfpgan_model.gfpgan_fix_faces(np.array(pp.image, dtype=np.uint8))File "<你的安装路径>/stable-diffusion-webui/modules/gfpgan_model.py", line 53, in gfpgan_fix_facesmodel = gfpgann()File "<你的安装路径>/stable-diffusion-webui/modules/gfpgan_model.py", line 40, in gfpgannmodel = gfpgan_constructor(model_path=model_file, upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None, device=devices.device_gfpgan)File "<你的安装路径>/stable-diffusion-webui/venv/lib/python3.10/site-packages/gfpgan/utils.py", line 79, in __init__self.face_helper = FaceRestoreHelper(File "<你的安装路径>/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/utils/face_restoration_helper.py", line 99, in __init__self.face_det = init_detection_model(det_model, half=False, device=self.device, model_rootpath=model_rootpath)File "<你的安装路径>/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/detection/__init__.py", line 18, in init_detection_modelmodel_path = load_file_from_url(File "<你的安装路径>/stable-diffusion-webui/modules/gfpgan_model.py", line 94, in facex_load_file_from_urlreturn facex_load_file_from_url_orig(**dict(kwargs, save_dir=model_path, model_dir=None))File "<你的安装路径>/stable-diffusion-webui/venv/lib/python3.10/site-packages/facexlib/utils/misc.py", line 77, in load_file_from_urldownload_url_to_file(url, cached_file, hash_prefix=None, progress=progress)File "<你的安装路径>/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/hub.py", line 611, in download_url_to_fileu = urlopen(req)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 216, in urlopenreturn opener.open(url, data, timeout)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 519, in openresponse = self._open(req, data)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 536, in _openresult = self._call_chain(self.handle_open, protocol, protocol +File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chainresult = func(*args)File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1391, in https_openreturn self.do_open(http.client.HTTPSConnection, req,File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 1351, in do_openraise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>^CInterrupted with signal 2 in <frame at 0x2a9396480, file '<你的安装路径>/stable-diffusion-webui/webui.py', line 209, code wait_on_server> 

如果没有代理的话,可以参考 https://zhuanlan.zhihu.com/p/609577723?utm_id=0
使用 ghproxy 来解决,但是需要修改的地方较多

最后附上两张ai生成的图片,使用的mbp14 2021 款,性能有限都是跑的低分辨率图片

请添加图片描述
请添加图片描述


http://www.ppmy.cn/news/1546322.html

相关文章

【大数据学习 | kafka高级部分】kafka的快速读写

1. 追加写 根据以上的部分我们发现存储的方式比较有规划是对于后续查询非常便捷的&#xff0c;但是这样存储是不是会更加消耗存储性能呢&#xff1f; 其实kafka的数据存储是追加形式的&#xff0c;也就是数据在存储到文件中的时候是以追加方式拼接到文件末尾的&#xff0c;这…

单臂路由技术,eNSP实验讲解

单臂路由技术&#xff0c;eNSP实验讲解 一、简要介绍1、概念2、工作原理3、优点4、缺点5、应用场景举例 二、eNSP仿真实验1、步骤一&#xff1a;2、步骤二&#xff1a;3、步骤三&#xff1a;4、步骤四&#xff1a; 三、总结。 一、简要介绍 1、概念 单臂路由&#xff08;Rout…

Spleeter:音频分离的革命性工具

目录 什么是Spleeter&#xff1f;Spleeter的工作原理Spleeter的应用场景Spleeter的技术优势Spleeter的挑战与局限性结论 什么是Spleeter&#xff1f; Spleeter 是一个由 Deezer 开发的开源音频源分离工具。它基于深度学习技术&#xff0c;尤其是卷积神经网络&#xff08;CNN&a…

42.第二阶段x86游戏实战2-lua寻找状态指针

免责声明&#xff1a;内容仅供学习参考&#xff0c;请合法利用知识&#xff0c;禁止进行违法犯罪活动&#xff01; 本次游戏没法给 内容参考于&#xff1a;微尘网络安全 本人写的内容纯属胡编乱造&#xff0c;全都是合成造假&#xff0c;仅仅只是为了娱乐&#xff0c;请不要…

websphere CVE-2015-7450反序列化和弱口令,后台Getshell

靶场安装 docker pull iscrosales/websphere7docker run -d -p 9060:9060 -p 9043:9043 -p 8880:8880 -p 9080:9080 iscrosales/websphere7 端口&#xff1a; 9080—web(http)应用访问端口、9443—web(https)应用访问端口、9060—管理后台访问端口、9043—管理控制台安全端口…

WPF中的依赖属性

1.创建项目后下载两个NuGet程序包 2.创建一个MyButton类继承Button MyButton类如下&#xff1a; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Contro…

大数据新视界 -- 大数据大厂之 Impala 性能优化:为企业决策加速的核心力量(下)(14/30)

&#x1f496;&#x1f496;&#x1f496;亲爱的朋友们&#xff0c;热烈欢迎你们来到 青云交的博客&#xff01;能与你们在此邂逅&#xff0c;我满心欢喜&#xff0c;深感无比荣幸。在这个瞬息万变的时代&#xff0c;我们每个人都在苦苦追寻一处能让心灵安然栖息的港湾。而 我的…

Linux环境基础开发工具的使用

Linux软件包管理器yum yum是一个软件下载安装管理的客户端&#xff0c;相当于手机上的应用商店 Linux中软件包可能存在依赖关系&#xff0c;而yum会帮我们解决依赖关系的问题 Linux系统&#xff08;centos&#xff09;的生态 安装软件的方式&#xff1a;源代码安装、rpm包安…