seed wildcards

This commit is contained in:
lilly
2023-03-25 02:53:15 +09:00
parent 5de0819c15
commit 4596db540c
4 changed files with 35 additions and 30 deletions
+26 -1
View File
@@ -18,7 +18,11 @@ else:
class CLIPTextEncodeWildcards:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True}), "clip": ("CLIP", )}}
return {
"required": {
"text": ("STRING", {"multiline": True}), "clip": ("CLIP", )
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"
@@ -28,3 +32,24 @@ class CLIPTextEncodeWildcards:
r=wildcards.run(text)
print(f"[green]encode : [/green]",r)
return ([[clip.encode(r), {}]], )
class CLIPTextEncodeWildcards2:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"text": ("STRING", {"multiline": True}), "clip": ("CLIP", ),
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"
CATEGORY = "conditioning"
def encode(self, seed, clip, text):
random.seed(seed)
r=wildcards.run(text)
print(f"[green]encode : [/green]",r)
return ([[clip.encode(r), {}]], )
+5 -3
View File
@@ -44,11 +44,13 @@ if not md.startswith("custom_nodes."):
NODE_CLASS_MAPPINGS = {
}
def add(name):
def add(name,list=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}")
print(f"Load ok : {name}", style="bold green")
except Exception:
console.print_exception()
@@ -57,7 +59,7 @@ if not md.startswith("custom_nodes."):
add("CheckpointLoaderRandom")
add("CheckpointLoaderSimpleText")
add("CLIPTextEncodeWildcards")
add("CLIPTextEncodeWildcards","CLIPTextEncodeWildcards2")
add("LoraLoaderText")
add("LoraLoaderTextRandom")
add("Random_Sampler")
@@ -66,4 +68,4 @@ if not md.startswith("custom_nodes."):
add("SaveImageSimple")
#add("test")
console.rule(" finit end ", style="bold green")
console.rule(" init end ", style="bold green")
+1 -23
View File
@@ -1,13 +1,11 @@
import sys
import json
import ast
import os
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
from ConsoleColor import print, console
else:
from .ConsoleColor import print, console
#print(__file__)
#print(os.path.basename(__file__))
"""
import psutil
@@ -47,23 +45,3 @@ mainFile = os.path.abspath(sys.modules['__main__'].__file__)
print("os.path.abspath(sys.modules\['__main__'].__file__) : " + mainFile ,style="bold CYAN")
mainfolder = os.path.dirname(mainFile)
print("os.path.dirname(mainFile) : " + mainfolder , style="bold CYAN")
def jsondic(full,dic,update=False):
path=os.path.split(full)[0]
if not os.path.exists(path):
os.makedirs(path)
#with open(f"./RandomLoop/chars-{time.strftime('_%Y%m%d_%H%M%S')}.json", 'w', encoding='utf-8') as file:
if os.path.exists(full):
with open(full, 'r', encoding='utf-8') as file:
tmp=json.load(file)
if update:
dic.update(tmp)
else:
dic=(tmp)
else:
with open(full, 'w', encoding='utf-8') as file:
json.dump(dic, file, sort_keys=False, indent=4)
return path
+3 -3
View File
@@ -166,7 +166,7 @@ class wildcards:
#print(__name__)
#if __name__ == '__main__' :
# 테스트용
test="{3$$a1|{b2|c3|}|d4|{-$$|f|g}|{-2$$h||i}|{1-$$j|k|}}/{$$l|m|}/{0$$n|}"
print("[green]wildcards test : [/green]",wildcards.run(test))
#test="{3$$a1|{b2|c3|}|d4|{-$$|f|g}|{-2$$h||i}|{1-$$j|k|}}/{$$l|m|}/{0$$n|}"
#print("[green]wildcards test : [/green]",wildcards.run(test))
#print("wildcards test : "+wildcards.run("{9$$a|b}"))
print("[green]wildcards test : [/green]",wildcards.run("__my__"))
#print("[green]wildcards test : [/green]",wildcards.run("__my__"))