Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add a way to add patches to the input block.

comfyanonymous94cc718e9c42
diff --git a/comfy/ldm/modules/diffusionmodules/openaimodel.py b/comfy/ldm/modules/diffusionmodules/openaimodel.py
index 49c1e8cbb..cac0dfb65 100644
--- a/comfy/ldm/modules/diffusionmodules/openaimodel.py
+++ b/comfy/ldm/modules/diffusionmodules/openaimodel.py
@@ -624,6 +624,11 @@ class UNetModel(nn.Module):
transformer_options["block"] = ("input", id)
h = forward_timestep_embed(module, h, emb, context, transformer_options)
h = apply_control(h, control, 'input')
+ if "input_block_patch" in transformer_patches:
+ patch = transformer_patches["input_block_patch"]
+ for p in patch:
+ h = p(h, transformer_options)
+
hs.append(h)
transformer_options["block"] = ("middle", 0)
diff --git a/comfy/model_patcher.py b/comfy/model_patcher.py
index 1c36855de..023684331 100644
--- a/comfy/model_patcher.py
+++ b/comfy/model_patcher.py
@@ -96,6 +96,9 @@ class ModelPatcher:
def set_model_attn2_output_patch(self, patch):
self.set_model_patch(patch, "attn2_output_patch")
+ def set_model_input_block_patch(self, patch):
+ self.set_model_patch(patch, "input_block_patch")
+
def set_model_output_block_patch(self, patch):
self.set_model_patch(patch, "output_block_patch")