Skip to content

Commit

Permalink
Add CLIPTextEncodeHunyuanDiT.
Browse files Browse the repository at this point in the history
Useful for testing what each text encoder does.
  • Loading branch information
comfyanonymous committed Jul 26, 2024
1 parent b6779d8 commit 6225a78
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions comfy_extras/nodes_hunyuan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class CLIPTextEncodeHunyuanDiT:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"clip": ("CLIP", ),
"bert": ("STRING", {"multiline": True, "dynamicPrompts": True}),
"mt5xl": ("STRING", {"multiline": True, "dynamicPrompts": True}),
}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"

CATEGORY = "advanced/conditioning"

def encode(self, clip, bert, mt5xl):
tokens = clip.tokenize(bert)
tokens["mt5xl"] = clip.tokenize(mt5xl)["mt5xl"]

output = clip.encode_from_tokens(tokens, return_pooled=True, return_dict=True)
cond = output.pop("cond")
return ([[cond, output]], )

NODE_CLASS_MAPPINGS = {
"CLIPTextEncodeHunyuanDiT": CLIPTextEncodeHunyuanDiT,
}
1 change: 1 addition & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,6 +2037,7 @@ def init_builtin_extra_nodes():
"nodes_sd3.py",
"nodes_gits.py",
"nodes_controlnet.py",
"nodes_hunyuan.py",
]

import_failed = []
Expand Down

0 comments on commit 6225a78

Please sign in to comment.