Skip to content

Commit

Permalink
Don't merge weights when shapes don't match and print a warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jun 22, 2023
1 parent f87ec10 commit 9f83b09
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion comfy/sd.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@ def patch_model(self):
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]
Expand Down

0 comments on commit 9f83b09

Please sign in to comment.