CLIPTextEncodeWildcards3

This commit is contained in:
lilly
2023-03-30 15:22:18 +09:00
parent f7d40d0b2d
commit 3472043e28
2 changed files with 42 additions and 7 deletions
+33 -2
View File
@@ -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), {}]], )
+9 -5
View File
@@ -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")