MacOS 上使用 python 3.8 版本安装运行 Stable Diffusion 时,有如下报错
Error loading script: lora_script.py
Traceback (most recent call last):
File "/Users/admin/diy/stable-diffusion-webui/modules/scripts.py", line 256, in load_scripts
script_module = script_loading.load_module(scriptfile.path)
File "/Users/admin/diy/stable-diffusion-webui/modules/script_loading.py", line 11, in load_module
module_spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/admin/diy/stable-diffusion-webui/extensions-builtin/Lora/scripts/lora_script.py", line 4, in <module>
import lora
File "/Users/admin/diy/stable-diffusion-webui/extensions-builtin/Lora/lora.py", line 238, in <module>
def lora_apply_weights(self: torch.nn.Conv2d | torch.nn.Linear | torch.nn.MultiheadAttention):
TypeError: unsupported operand type(s) for |: 'type' and 'type'
这是因为之前老版本的 python 3.8 的兼容问题。
解决办法:
1. 方法一:升级 python 版本至 3.9+
2. 方法二:在 `lora.py` 文件中增加代码:from __future__ import annotations:文章来源:https://www.toymoban.com/news/detail-516561.html
from __future__ import annotations
import glob
import os
import re
import torch
from modules import shared, devices, sd_models, errors
Problem solved~文章来源地址https://www.toymoban.com/news/detail-516561.html
到了这里,关于Stable Diffusion 运行报错 TypeError: unsupported operand type(s) for |: ‘type‘ and ‘type‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!