Stable Diffusion如何加载LoRA
首先,在SD中加载LoRA模型的方式为:prompt栏输入对应字符以调用,形如:
为了使SD能正常读取到LoRA模型,需要把LoRA模型移动到 /SD安装目录/models/Lora 中
即为:
模型导入完成后,需重启webUI,使得SD正常显示安装好的LoRA模型
重启后选择LoRA这一栏,打开即可看到我们安装好的模型
点击安装好的模型.对应的字符被自动添加至prompt栏中
修改模型名称后的数字即可修改LoRA权重,进行微调
Stable Diffusion 安装时遇到「您当前安装的PyTorch及其附属库并不支持使用您在“生产引擎”中所选择的设备,继续运行将导致启动失败。 请前往“高级选项-环境维护”面板安装对应PyTorch版本」要怎么办
在启动器中重新选择pytorch即可
这里可以看zhihu上Stable Diffusion常见问题与解答(持续更新……)的Q32
运行不起来,报错 RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! when resuming training
常见问题与解答 Q73
个人重新安装pytorch后重启几次解决了,有点神奇
Weights only load failed. This file can still be loaded, to do so you have two options, 1mdo those steps only if you trust the source of the checkpoint 0m.
(1) In PyTorch 2.6, we changed the default value of the weights_only
argument in torch.load
from False
to True
. Re-running torch.load
with weights_only
set to False
will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with weights_only=True
please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.DetectionModel was not an allowed global by default. Please use torch.serialization.add_safe_globals([DetectionModel])
or the torch.serialization.safe_globals([DetectionModel])
context manager to allowlist this global if you trust this class/function.
常见问题与解答 Q84
- 从 PyTorch 2.6 版本开始,
torch.load
默认出于安全考虑,只允许加载权重(weights),不执行保存文件里的 Python 代码。 - 但是你要加载的
.pt
文件(比如一些模型权重文件)里面,保存了完整模型结构,而且用到了比如ultralytics.nn.tasks.DetectionModel
这样的自定义类。 - PyTorch 不认识这个类,而且默认又不让加载任意代码,所以就报错了。
- 方法一:不要使用 .pt模型,换成 .safetensors模型
- 方法二:找到报错节点的文件夹,例如:ComfyUI\custom_nodes\节点名字\。搜索 torch.load 打开文件,你会看到一行类似这样的代码:model = torch.load(ckpt_path)或者:torch.load(path)。改成这样:model = torch.load(ckpt_path, weights_only=False)或者:orch.load(path, weights_only=False)保存 .py 文件,关闭并重新启动 ComfyUI,让改动生效。
这里我推荐方法一也不是没办法用老的pt模型
使用SD的「模型转换」工具
进行如下操作
如何让出的图大体保持一致?
同种子
具体看这篇模型推荐
- animagine-xl-4.0这里选opt,为优化版(optimized)
Views: 9