From 9f83b098c9c919fb8eb32e93ca5cca994346dae4 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Thu, 22 Jun 2023 19:08:31 -0400 Subject: [PATCH] Don't merge weights when shapes don't match and print a warning. --- comfy/sd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comfy/sd.py b/comfy/sd.py index 7ed22d81..64c95531 100644 --- a/comfy/sd.py +++ b/comfy/sd.py @@ -390,7 +390,11 @@ class ModelPatcher: weight *= strength_model if len(v) == 1: - weight += alpha * (v[0]).type(weight.dtype).to(weight.device) + w1 = v[0] + if w1.shape != weight.shape: + print("WARNING SHAPE MISMATCH {} WEIGHT NOT MERGED {} != {}".format(key, w1.shape, weight.shape)) + else: + weight += alpha * w1.type(weight.dtype).to(weight.device) elif len(v) == 4: #lora/locon mat1 = v[0] mat2 = v[1]