From 3472043e284255e97c9bead24cacf40d4a8b2993 Mon Sep 17 00:00:00 2001 From: lilly Date: Thu, 30 Mar 2023 15:22:18 +0900 Subject: [PATCH] CLIPTextEncodeWildcards3 --- CLIPTextEncodeWildcards.py | 35 +++++++++++++++++++++++++++++++++-- __init__.py | 14 +++++++++----- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CLIPTextEncodeWildcards.py b/CLIPTextEncodeWildcards.py index 43ccc1e..0616381 100644 --- a/CLIPTextEncodeWildcards.py +++ b/CLIPTextEncodeWildcards.py @@ -31,7 +31,7 @@ class CLIPTextEncodeWildcards: def encode(self, clip, text): print(f"[green]text : [/green]",text) r=wildcards.run(text) - print(f"[green]encode : [/green]",r) + print(f"[green]result : [/green]",r) return ([[clip.encode(r), {}]], ) class CLIPTextEncodeWildcards2: @@ -53,5 +53,36 @@ class CLIPTextEncodeWildcards2: random.seed(seed) print(f"[green]text : [/green]",text) r=wildcards.run(text) - print(f"[green]encode : [/green]",r) + print(f"[green]result : [/green]",r) return ([[clip.encode(r), {}]], ) + + + +class CLIPTextEncodeWildcards3: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "clip": ("CLIP", ), + "positive": ("STRING", {"multiline": True}), + "negative": ("STRING", {"multiline": True}), + "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}), + + } + } + RETURN_TYPES = ("CONDITIONING","CONDITIONING") + FUNCTION = "encode" + + CATEGORY = "conditioning" + + def encode(self, seed, clip, positive, negative): + random.seed(seed) + print(f"[green]positive : [/green]",positive) + positive=wildcards.run(positive) + print(f"[green]result : [/green]",positive) + print(f"[green]negative : [/green]",negative) + negative=wildcards.run(negative) + print(f"[green]result : [/green]",negative) + return ([[clip.encode(positive), {}]], [[clip.encode(negative), {}]], ) + + diff --git a/__init__.py b/__init__.py index 9a47fed..195f730 100644 --- a/__init__.py +++ b/__init__.py @@ -44,13 +44,17 @@ if not md.startswith("custom_nodes."): NODE_CLASS_MAPPINGS = { } - def add(name,list=None): + def add(name,clist=None): #print(f"Load : {name}") try: pkg = importlib.import_module(f"{md}.{name}") - NODE_CLASS_MAPPINGS[name]=eval(f"pkg.{name}") - if type(list) is str: - NODE_CLASS_MAPPINGS[list]=eval(f"pkg.{list}") + if clist is None: + NODE_CLASS_MAPPINGS[name]=eval(f"pkg.{name}") + elif type(clist) is str: + NODE_CLASS_MAPPINGS[clist]=eval(f"pkg.{clist}") + elif type(clist) is list: + for c in clist: + NODE_CLASS_MAPPINGS[c]=eval(f"pkg.{c}") print(f"Load ok : {name}", style="bold green") except Exception: console.print_exception() @@ -59,7 +63,7 @@ if not md.startswith("custom_nodes."): add("CheckpointLoaderRandom") add("CheckpointLoaderSimpleText") - add("CLIPTextEncodeWildcards","CLIPTextEncodeWildcards2") + add("CLIPTextEncodeWildcards",["CLIPTextEncodeWildcards","CLIPTextEncodeWildcards2","CLIPTextEncodeWildcards3"]) add("LoraLoaderText") add("LoraLoaderTextRandom") add("Random_Sampler")