?
最近發(fā)現(xiàn)了 Stable Diffusion 這個(gè)好玩的ai繪畫工具,不得不感嘆現(xiàn)在ai工具已經(jīng)進(jìn)化到這么簡單易用的程度,只要下載對應(yīng)的模型就可以生成各種有意思的圖片
就算你沒有編程基礎(chǔ),跟著教程也能弄出來
不過使用過程中發(fā)現(xiàn)部分功能無法使用
查看日志發(fā)現(xiàn)是一些圖片生成過程中需要的模型無法下載
在終端export代理地址之后,發(fā)現(xiàn)依舊報(bào)錯
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
這個(gè)報(bào)錯信息可以看出來就是Python無法驗(yàn)證SSL證書而引起的,搜索之后發(fā)現(xiàn)解決方法就是執(zhí)行如下代碼關(guān)閉ssl證書的認(rèn)證
# 導(dǎo)入對應(yīng)庫
import ssl
# 全局關(guān)閉ssl驗(yàn)證
ssl._create_default_https_context = ssl._create_unverified_context
跟隨 Stable Diffusion 的日志查看到第一個(gè)加載的python文件為 lanuch.py ,就位于 stable-diffusion-webui 根目錄下,直接在文件頂部加就可以了
之后重啟 stable-diffusion-webui,再次使用相同功能生成圖片,模型下載成功
完整報(bào)錯如下,便于大家檢索:”
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.zghlxwxcb.cn/news/detail-449327.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-449327.html
到了這里,關(guān)于使用代理時(shí)Stable Diffusion無法正常下載各類模型的解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!