Support for Qwen Diffsynth Controlnets canny and depth. (#9465)

These are not real controlnets but actually a patch on the model so they
will be treated as such.

Put them in the models/model_patches/ folder.

Use the new ModelPatchLoader and QwenImageDiffsynthControlnet nodes.
This commit is contained in:
comfyanonymous
2025-08-20 19:26:37 -07:00
committed by GitHub
parent e73a9dbe30
commit 0963493a9c
7 changed files with 184 additions and 1 deletions

View File

@@ -416,6 +416,7 @@ class QwenImageTransformer2DModel(nn.Module):
)
patches_replace = transformer_options.get("patches_replace", {})
patches = transformer_options.get("patches", {})
blocks_replace = patches_replace.get("dit", {})
for i, block in enumerate(self.transformer_blocks):
@@ -436,6 +437,12 @@ class QwenImageTransformer2DModel(nn.Module):
image_rotary_emb=image_rotary_emb,
)
if "double_block" in patches:
for p in patches["double_block"]:
out = p({"img": hidden_states, "txt": encoder_hidden_states, "x": x, "block_index": i})
hidden_states = out["img"]
encoder_hidden_states = out["txt"]
hidden_states = self.norm_out(hidden_states, temb)
hidden_states = self.proj_out(hidden_states)