From ebfe7a5679e5200527fc18eb1f56115ca0ddd3f4 Mon Sep 17 00:00:00 2001 From: ethan Date: Mon, 10 Feb 2025 19:54:44 -0800 Subject: [PATCH] fix the issue for model first inference with lora --- comfy/model_patcher.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py index a2a26f17..31c98a04 100644 --- a/comfy/model_patcher.py +++ b/comfy/model_patcher.py @@ -463,21 +463,13 @@ class ModelPatcher: key = k[0] if len(k) > 2: function = k[2] - - if key in model_sd: + org_key=key.replace("diffusion_model", "diffusion_model._orig_mod") + if key in model_sd or org_key in model_sd: p.add(k) current_patches = self.patches.get(key, []) current_patches.append((strength_patch, patches[k], strength_model, offset, function)) self.patches[key] = current_patches - else: - new_key=key.replace("diffusion_model", "diffusion_model._orig_mod") - if new_key in model_sd: - p.add(k) - if key in self.patches: - self.patches.pop(key) - current_patches = self.patches.get(new_key, []) - current_patches.append((strength_patch, patches[k], strength_model, offset, function)) - self.patches[new_key] = current_patches + self.patches[org_key] = current_patches self.patches_uuid = uuid.uuid4() return list(p)