Skip to content

Commit

Permalink
Add a node to give the controlnet a prompt different from the unet.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Feb 10, 2024
1 parent f44225f commit 20e3da6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions comfy_extras/nodes_cond.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


class CLIPTextEncodeControlnet:
@classmethod
def INPUT_TYPES(s):
return {"required": {"clip": ("CLIP", ), "conditioning": ("CONDITIONING", ), "text": ("STRING", {"multiline": True})}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"

CATEGORY = "_for_testing/conditioning"

def encode(self, clip, conditioning, text):
tokens = clip.tokenize(text)
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
c = []
for t in conditioning:
n = [t[0], t[1].copy()]
n[1]['cross_attn_controlnet'] = cond
n[1]['pooled_output_controlnet'] = pooled
c.append(n)
return (c, )

NODE_CLASS_MAPPINGS = {
"CLIPTextEncodeControlnet": CLIPTextEncodeControlnet
}
1 change: 1 addition & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,7 @@ def init_custom_nodes():
"nodes_stable3d.py",
"nodes_sdupscale.py",
"nodes_photomaker.py",
"nodes_cond.py",
]

for node_file in extras_files:
Expand Down

0 comments on commit 20e3da6

Please sign in to comment.