From 6225a7827c17bc237167f8500029d282f4c91950 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Fri, 26 Jul 2024 13:04:48 -0400 Subject: [PATCH] Add CLIPTextEncodeHunyuanDiT. Useful for testing what each text encoder does. --- comfy_extras/nodes_hunyuan.py | 24 ++++++++++++++++++++++++ nodes.py | 1 + 2 files changed, 25 insertions(+) create mode 100644 comfy_extras/nodes_hunyuan.py diff --git a/comfy_extras/nodes_hunyuan.py b/comfy_extras/nodes_hunyuan.py new file mode 100644 index 00000000000..a3ac8cb0629 --- /dev/null +++ b/comfy_extras/nodes_hunyuan.py @@ -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, +} diff --git a/nodes.py b/nodes.py index fbdcb6c91ac..dc66dd3ef00 100644 --- a/nodes.py +++ b/nodes.py @@ -2037,6 +2037,7 @@ def init_builtin_extra_nodes(): "nodes_sd3.py", "nodes_gits.py", "nodes_controlnet.py", + "nodes_hunyuan.py", ] import_failed = []