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

news/2024/11/8 5:01:17 标签: stable diffusion

最近发现了 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.pth

Error completing request

Arguments: (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_open
    h.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 request
    self._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_request
    self.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 endheaders
    self._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_output
    self.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 send
    self.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 connect
    self.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_socket
    return 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 _create
    self.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_handshake
    self._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 f
    res = list(func(*args, **kwargs))
  File "<你的安装路径>/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "<你的安装路径>/stable-diffusion-webui/modules/postprocessing.py", line 56, in run_postprocessing
    scripts.scripts_postproc.run(pp, args)
  File "<你的安装路径>/stable-diffusion-webui/modules/scripts_postprocessing.py", line 130, in run
    script.process(pp, **process_args)
  File "<你的安装路径>/stable-diffusion-webui/scripts/postprocessing_gfpgan.py", line 26, in process
    restored_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_faces
    model = gfpgann()
  File "<你的安装路径>/stable-diffusion-webui/modules/gfpgan_model.py", line 40, in gfpgann
    model = 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_model
    model_path = load_file_from_url(
  File "<你的安装路径>/stable-diffusion-webui/modules/gfpgan_model.py", line 94, in facex_load_file_from_url
    return 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_url
    download_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_file
    u = 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 urlopen
    return 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 open
    response = 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 _open
    result = 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_chain
    result = 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_open
    return 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_open
    raise 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.niftyadmin.cn/n/5743260.html

相关文章

青少年编程与数学 02-003 Go语言网络编程 14课题、Go语言Udp编程

青少年编程与数学 02-003 Go语言网络编程 14课题、Go语言Udp编程 课题摘要:一、UDP编程1. 创建UDP连接&#xff08;服务器和客户端&#xff09;服务器端客户端 2. 读取和发送数据3. 关闭连接4. 错误处理5. 性能优化总结 二、UDP与TCP的区别1. 连接性2. 可靠性3. 流量控制和拥塞…

分布式——BASE理论

简单来说&#xff1a; BASE&#xff08;Basically Available、Soft state、Eventual consistency&#xff09;是基于CAP理论逐步演化而来的&#xff0c;核心思想是即便不能达到强一致性&#xff08;Strong consistency&#xff09;&#xff0c;也可以根据应用特点采用适当的方…

vue3实现一个无缝衔接、滚动平滑的列表自动滚屏效果,支持鼠标移入停止移出滚动

文章目录 前言一、滚动元素相关属性回顾一、实现分析二、代码实现示例&#xff1a;2、继续添加功能&#xff0c;增加鼠标移入停止滚动、移出继续滚动效果2、继续完善 前言 列表自动滚屏效果常见于大屏开发场景中&#xff0c;本文将讲解用vue3实现一个无缝衔接、滚动平滑的列表自…

Spring Security特性(密码)

Spring Security特性(密码) Spring Security提供了对 认证&#xff08;authentication&#xff09; 的全面支持。认证是指我们如何验证试图访问特定资源的人的身份。一个常见的验证用户的方法是要求用户输入用户名和密码。一旦进行了认证&#xff0c;我们就知道了身份并可以执…

C++ 的异常处理详解

C 的异常处理详解 在编程过程中&#xff0c;错误和异常是不可避免的&#xff0c;合理的异常处理机制能够提高程序的健壮性。在 C 中&#xff0c;异常机制为捕获和处理错误提供了一种结构化的方式。本文将对 C 的异常处理进行详细探讨&#xff0c;包括异常的概念、如何抛出和捕…

用接地气的例子趣谈 WWDC 24 全新的 Swift Testing 入门(三)

概述 从 WWDC 24 开始&#xff0c;苹果推出了全新的测试机制&#xff1a;Swift Testing。利用它我们可以大幅度简化之前“老态龙钟”的 XCTest 编码范式&#xff0c;并且使得单元测试更加灵动自由&#xff0c;更符合 Swift 语言的优雅品味。 在这里我们会和大家一起初涉并领略…

压力测试,探索服务器性能瓶颈

什么是全链路压力测试&#xff1f; 全链路压力测试是指基于真实业务场景&#xff0c;通过模拟海量的用户请求&#xff0c;对整个后台服务进行压力测试&#xff0c;从而评估整个系统的性能水平。 创建全链路压力测试 第一步&#xff1a;准备测试数据 为了尽量模拟真实的业务…

RabbitMQ 高级特性——消息分发

文章目录 前言消息分发RabbitMQ 分发机制的应用场景1. 限流2. 负载均衡 前言 当 RabbitMQ 的队列绑定了多个消费者的时候&#xff0c;队列会把消息分发给不同的消费者&#xff0c;每条消息只会发送给订阅列表的一个消费者&#xff0c;但是呢&#xff0c;RabbitMQ 默认是以轮询…