Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
026ffb291b | ||
|
|
038ea91985 | ||
|
|
fe13add535 | ||
|
|
40ad60ab06 | ||
|
|
41be495672 | ||
|
|
059d59455c | ||
|
|
99a74bee92 | ||
|
|
3247eaec7e | ||
|
|
dd3420d15c | ||
|
|
eb17b381a6 | ||
|
|
6feccddcba | ||
|
|
7bd85c9544 | ||
|
|
01590a7839 | ||
|
|
cf91e6a57a | ||
|
|
1e7442625b | ||
|
|
f8863c5cb2 |
@@ -5,10 +5,10 @@ from folder_paths import *
|
|||||||
import random
|
import random
|
||||||
import os
|
import os
|
||||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||||
from ConsoleColor import print, console
|
from ConsoleColor import print, console, ccolor
|
||||||
from mypath import *
|
from mypath import *
|
||||||
else:
|
else:
|
||||||
from .ConsoleColor import print, console
|
from .ConsoleColor import print, console, ccolor
|
||||||
from .mypath import *
|
from .mypath import *
|
||||||
|
|
||||||
#print(__file__)
|
#print(__file__)
|
||||||
@@ -35,24 +35,13 @@ class CheckpointLoaderSimpleText:
|
|||||||
CATEGORY = "loaders"
|
CATEGORY = "loaders"
|
||||||
|
|
||||||
def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True):
|
def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True):
|
||||||
#ckpt_path =check_name_ckpt(name_split_choice(ckpt_name))
|
print(f"[{ccolor}]ckpt_name : [/{ccolor}]", ckpt_name)
|
||||||
print(f"ckpt_name",ckpt_name)
|
ckpt_path=getFullPath(ckpt_name,"checkpoints")
|
||||||
ns=name_split_choice(ckpt_name)
|
|
||||||
print(f"ns",ns)
|
|
||||||
ckpt_path =get_full_path("checkpoints",ns)
|
|
||||||
print(f"ckpt_path",ckpt_path)
|
|
||||||
if ckpt_path is None:
|
|
||||||
print(f"{ckpt_name} is none")
|
|
||||||
(name,fullpath)=filenameget(os.path.join(models_dir, "checkpoints")+"/**/"+ckpt_name+"*.safetensors")
|
|
||||||
if fullpath is None:
|
|
||||||
print(f"{name} is none")
|
|
||||||
return
|
|
||||||
ckpt_path=fullpath
|
|
||||||
try:
|
try:
|
||||||
out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
|
out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
|
||||||
return out
|
return out
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("CheckpointLoaderSimpleText Exception : "+ e)
|
console.print_exception()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ custom_theme = Theme({
|
|||||||
})
|
})
|
||||||
console = Console(theme=custom_theme)
|
console = Console(theme=custom_theme)
|
||||||
print=console.log
|
print=console.log
|
||||||
|
ccolor="bright_yellow"
|
||||||
"""
|
"""
|
||||||
print("test", style="bold white on blue")
|
print("test", style="bold white on blue")
|
||||||
print("test", style="bold green")
|
print("test", style="bold green")
|
||||||
|
|||||||
+9
-15
@@ -4,9 +4,11 @@ from nodes import *
|
|||||||
import folder_paths
|
import folder_paths
|
||||||
|
|
||||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||||
from ConsoleColor import print, console
|
from ConsoleColor import print, console, ccolor
|
||||||
|
from mypath import *
|
||||||
else:
|
else:
|
||||||
from .ConsoleColor import print, console
|
from .ConsoleColor import print, console, ccolor
|
||||||
|
from .mypath import *
|
||||||
|
|
||||||
class LoraLoaderText:
|
class LoraLoaderText:
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -31,23 +33,15 @@ class LoraLoaderText:
|
|||||||
|
|
||||||
def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
|
def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
|
||||||
|
|
||||||
|
print(f"[{ccolor}]lora_name : [/{ccolor}]", lora_name)
|
||||||
if lora_name is None or lora_name =="" :
|
if lora_name is None or lora_name =="" :
|
||||||
print("[red]No lora_name[/red] : ", lora_name)
|
|
||||||
return (strength_model, strength_clip)
|
|
||||||
|
|
||||||
if lora_name.endswith('.safetensors') or lora_name.endswith('.ckpt') :
|
|
||||||
lora_path = folder_paths.get_full_path("loras", lora_name)
|
|
||||||
|
|
||||||
else:
|
|
||||||
lora_path = folder_paths.get_full_path("loras", lora_name+'.safetensors')
|
|
||||||
print("[green]lora_path : [/green]"+ lora_path)
|
|
||||||
if lora_path is None:
|
|
||||||
lora_path = folder_paths.get_full_path("loras", lora_name+'.ckpt')
|
|
||||||
print("[green]lora_path : [/green]"+ lora_path)
|
|
||||||
if lora_path is None:
|
|
||||||
print("[red]No lora_name[/red] : ", lora_name)
|
print("[red]No lora_name[/red] : ", lora_name)
|
||||||
return (model, clip)
|
return (model, clip)
|
||||||
|
|
||||||
|
lora_path=getFullPath(lora_name,"lora")
|
||||||
|
if lora_path is None:
|
||||||
|
print("[red]No lora_path of lora_name [/red] : ", lora_name)
|
||||||
|
return (model, clip)
|
||||||
try:
|
try:
|
||||||
model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora_path, strength_model, strength_clip)
|
model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora_path, strength_model, strength_clip)
|
||||||
return (model_lora, clip_lora)
|
return (model_lora, clip_lora)
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ c
|
|||||||
__anotherfile__
|
__anotherfile__
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### reload card
|
||||||
|
|
||||||
|
call wildcards.card_load()
|
||||||
|
or
|
||||||
|
wildcards.run("{9$$-$$a|b|c}",True)
|
||||||
|
|
||||||
## for ComfyUI
|
## for ComfyUI
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import comfy.samplers
|
|||||||
import comfy.sd
|
import comfy.sd
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
|
||||||
import comfy_extras.clip_vision
|
#import comfy_extras.clip_vision
|
||||||
|
|
||||||
import model_management
|
import model_management
|
||||||
import importlib
|
import importlib
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import os, glob, sys
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] or __name__ =='__main__':
|
||||||
|
from ConsoleColor import print, console
|
||||||
|
from wildcards import wildcards
|
||||||
|
else:
|
||||||
|
from .ConsoleColor import print, console
|
||||||
|
from .wildcards import wildcards
|
||||||
|
|
||||||
|
|
||||||
|
class TextWildcards:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"text": ("STRING", {"multiline": True}),
|
||||||
|
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RETURN_TYPES = ("STRING","ASCII")
|
||||||
|
FUNCTION = "encode"
|
||||||
|
|
||||||
|
CATEGORY = "utils"
|
||||||
|
|
||||||
|
def encode(self, seed, text):
|
||||||
|
random.seed(seed)
|
||||||
|
print(f"[green]text : [/green]",text)
|
||||||
|
r=wildcards.run(text)
|
||||||
|
print(f"[green]result : [/green]",r)
|
||||||
|
return (r, r)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import folder_paths
|
||||||
|
import comfy.sd
|
||||||
|
import os
|
||||||
|
from folder_paths import *
|
||||||
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||||
|
from ConsoleColor import print, console, ccolor
|
||||||
|
from mypath import *
|
||||||
|
else:
|
||||||
|
from .ConsoleColor import print, console, ccolor
|
||||||
|
from .mypath import *
|
||||||
|
|
||||||
|
class VAELoaderText:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required": {
|
||||||
|
"vae_name": ("STRING", {
|
||||||
|
"multiline": False, #True if you want the field to look like the one on the ClipTextEncode node
|
||||||
|
"default": random.choice(folder_paths.get_filename_list("vae"))
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
RETURN_TYPES = ("VAE",)
|
||||||
|
FUNCTION = "load_vae"
|
||||||
|
|
||||||
|
CATEGORY = "loaders"
|
||||||
|
|
||||||
|
#TODO: scale factor?
|
||||||
|
def load_vae(self, vae_name):
|
||||||
|
print(f"[{ccolor}]vae_name : [/{ccolor}]", vae_name)
|
||||||
|
vae_path=getFullPath(vae_name,"vae")
|
||||||
|
try:
|
||||||
|
vae = comfy.sd.VAE(ckpt_path=vae_path)
|
||||||
|
return (vae,)
|
||||||
|
except Exception as e:
|
||||||
|
console.print_exception()
|
||||||
|
return
|
||||||
+40
-13
@@ -1,9 +1,24 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
|
||||||
|
|
||||||
|
print(f"__name__ : {__name__}")
|
||||||
|
print(f"__file__ : {__file__}")
|
||||||
|
print(f"os.path.basename(__file__) : {os.path.basename(__file__)}")
|
||||||
|
print(f"os.path.splitext(os.path.basename(__file__))[0] : {os.path.splitext(os.path.basename(__file__))[0]}")
|
||||||
|
#print(f"os.path.basename(__file__) : {os.path.basename('/ComfyUI_windows_portable/ComfyUI/custom_nodes/ComfyUI_node_Lilly/__init__.py')}")
|
||||||
|
#print(f"os.path.splitext(os.path.basename(__file__))[0] : {os.path.splitext(os.path.basename('/ComfyUI_windows_portable/ComfyUI/custom_nodes/ComfyUI_node_Lilly/__init__.py'))[0]}")
|
||||||
|
|
||||||
|
wd = os.getcwd()
|
||||||
|
print("working directory : ", wd)
|
||||||
|
|
||||||
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] or __name__ =='__main__':
|
||||||
from ConsoleColor import print, console
|
from ConsoleColor import print, console
|
||||||
|
#md="custom_nodes.ComfyUI_node_Lilly."
|
||||||
else:
|
else:
|
||||||
from .ConsoleColor import print, console
|
from .ConsoleColor import print, console
|
||||||
|
#md="custom_nodes.ComfyUI_node_Lilly."
|
||||||
|
md="custom_nodes.ComfyUI_node_Lilly."
|
||||||
#print(__file__)
|
#print(__file__)
|
||||||
#print(os.path.basename(__file__))
|
#print(os.path.basename(__file__))
|
||||||
|
|
||||||
@@ -21,13 +36,14 @@ else:
|
|||||||
#path, filename = os.path.split(absFilePath)
|
#path, filename = os.path.split(absFilePath)
|
||||||
#print("Script file path is {}, filename is {}".format(path, filename))
|
#print("Script file path is {}, filename is {}".format(path, filename))
|
||||||
|
|
||||||
wd = os.getcwd()
|
|
||||||
#print("working directory : ", wd)
|
|
||||||
|
|
||||||
nm=os.path.abspath(__name__)
|
#
|
||||||
|
#nm=os.path.abspath(__name__)
|
||||||
|
#nm=os.path.abspath(__name__)
|
||||||
#print("abspath __name__ : ", nm)
|
#print("abspath __name__ : ", nm)
|
||||||
|
#print("abspath __name__ : ", nm)
|
||||||
md=nm.replace(wd+"\\","")
|
#
|
||||||
|
#md=nm.replace(wd+"\\","")
|
||||||
#print("import name", md)
|
#print("import name", md)
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@@ -36,25 +52,34 @@ md=nm.replace(wd+"\\","")
|
|||||||
#else:
|
#else:
|
||||||
# print(f"{md!r} not in sys.modules")
|
# print(f"{md!r} not in sys.modules")
|
||||||
|
|
||||||
if not md.startswith("custom_nodes."):
|
#import importlib
|
||||||
|
#import ComfyUI_node_Lilly
|
||||||
import importlib
|
|
||||||
#from custom_nodes.ComfyUI_node_Lilly import eval(f"{name}")
|
#from custom_nodes.ComfyUI_node_Lilly import eval(f"{name}")
|
||||||
|
#print(dir(ComfyUI_node_Lilly))
|
||||||
|
#print(dir(ComfyUI_node_Lilly.ComfyUI_node_Lilly))
|
||||||
|
|
||||||
|
#print(__name__ == md)
|
||||||
|
#print(__name__ != md)
|
||||||
|
#print(__name__ == "ComfyUI_node_Lilly")
|
||||||
|
#print(__name__ != "ComfyUI_node_Lilly")
|
||||||
|
if __name__ == "ComfyUI_node_Lilly" :
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def add(name,clist=None):
|
def add(name,clist=None):
|
||||||
#print(f"Load : {name}")
|
#print(f"Load : {name}")
|
||||||
try:
|
try:
|
||||||
pkg = importlib.import_module(f"{md}.{name}")
|
#pkg = importlib.import_module(f"{md}{name}")
|
||||||
|
#eval(f"{md}{name}")
|
||||||
|
exec(f"import {md}{name}")
|
||||||
if clist is None:
|
if clist is None:
|
||||||
NODE_CLASS_MAPPINGS[name]=eval(f"pkg.{name}")
|
NODE_CLASS_MAPPINGS[name]=eval(f"{md}{name}.{name}")
|
||||||
elif type(clist) is str:
|
elif type(clist) is str:
|
||||||
NODE_CLASS_MAPPINGS[clist]=eval(f"pkg.{clist}")
|
NODE_CLASS_MAPPINGS[clist]=eval(f"{md}{name}.{clist}")
|
||||||
elif type(clist) is list:
|
elif type(clist) is list:
|
||||||
for c in clist:
|
for c in clist:
|
||||||
NODE_CLASS_MAPPINGS[c]=eval(f"pkg.{c}")
|
NODE_CLASS_MAPPINGS[c]=eval(f"{md}{name}.{c}")
|
||||||
|
|
||||||
print(f"Load ok : {name}", style="bold green")
|
print(f"Load ok : {name}", style="bold green")
|
||||||
except Exception:
|
except Exception:
|
||||||
console.print_exception()
|
console.print_exception()
|
||||||
@@ -68,8 +93,10 @@ if not md.startswith("custom_nodes."):
|
|||||||
add("LoraLoaderTextRandom")
|
add("LoraLoaderTextRandom")
|
||||||
add("Random_Sampler")
|
add("Random_Sampler")
|
||||||
add("VAELoaderDecode")
|
add("VAELoaderDecode")
|
||||||
|
add("VAELoaderText")
|
||||||
add("SimpleSampler",["SimpleSampler","SimpleSamplerVAE"])
|
add("SimpleSampler",["SimpleSampler","SimpleSamplerVAE"])
|
||||||
add("SaveImageSimple")
|
add("SaveImageSimple")
|
||||||
|
add("TextWildcards")
|
||||||
#add("test")
|
#add("test")
|
||||||
|
|
||||||
console.rule(" init end ", style="bold green")
|
console.rule(" init end ", style="bold green")
|
||||||
@@ -3,6 +3,7 @@ import json
|
|||||||
import ast
|
import ast
|
||||||
import os, glob
|
import os, glob
|
||||||
import random
|
import random
|
||||||
|
from folder_paths import *
|
||||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||||
from ConsoleColor import print, console
|
from ConsoleColor import print, console
|
||||||
else:
|
else:
|
||||||
@@ -79,3 +80,33 @@ def filenameget(v_path):
|
|||||||
name=os.path.basename(fullpath)
|
name=os.path.basename(fullpath)
|
||||||
#r_path=[os.path.basename(fullpath) for fullpath in fullpaths]
|
#r_path=[os.path.basename(fullpath) for fullpath in fullpaths]
|
||||||
return (name,fullpath)
|
return (name,fullpath)
|
||||||
|
|
||||||
|
# "test","vae",["pt","safetensors"]
|
||||||
|
def getFullPath(p,k,el=["safetensors","ckpt","pt"]):
|
||||||
|
if os.path.isabs(p):
|
||||||
|
path=p
|
||||||
|
else:
|
||||||
|
path=os.path.join(models_dir,k+"/**/",p)
|
||||||
|
#print(f"path : ", path)
|
||||||
|
t=False
|
||||||
|
for e in el:
|
||||||
|
if p.endswith('.'+e):
|
||||||
|
t=True
|
||||||
|
break
|
||||||
|
if t:
|
||||||
|
files=glob.glob(path, recursive=True)
|
||||||
|
else:
|
||||||
|
for e in el:
|
||||||
|
t=path+"."+e
|
||||||
|
#print(f"t : ", t)
|
||||||
|
files=glob.glob(t, recursive=True)
|
||||||
|
if len(files):
|
||||||
|
break
|
||||||
|
result=None
|
||||||
|
#print(f"files : ", files)
|
||||||
|
if len(files):
|
||||||
|
result=random.choice(files)
|
||||||
|
print(f"result : ", result)
|
||||||
|
else:
|
||||||
|
print("[red]No file in path[/red] : ", path)
|
||||||
|
return result
|
||||||
+9
-4
@@ -3,9 +3,9 @@ import random
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] or __name__ =='__main__':
|
if __name__ == os.path.splitext(os.path.basename(__file__))[0] or __name__ =='__main__':
|
||||||
from ConsoleColor import print, console
|
from ConsoleColor import print, console, ccolor
|
||||||
else:
|
else:
|
||||||
from .ConsoleColor import print, console
|
from .ConsoleColor import print, console , ccolor
|
||||||
#print(__file__)
|
#print(__file__)
|
||||||
#print(os.path.basename(__file__))
|
#print(os.path.basename(__file__))
|
||||||
#print(os.getcwd())
|
#print(os.getcwd())
|
||||||
@@ -25,6 +25,7 @@ class wildcards:
|
|||||||
recard = re.compile(r"(__)(.*?)(__)")
|
recard = re.compile(r"(__)(.*?)(__)")
|
||||||
|
|
||||||
# 카드 목록
|
# 카드 목록
|
||||||
|
is_card_Load = False
|
||||||
cards = {}
|
cards = {}
|
||||||
seperator=", "
|
seperator=", "
|
||||||
loop_max=50
|
loop_max=50
|
||||||
@@ -152,10 +153,14 @@ class wildcards:
|
|||||||
wildcards.cards=cards
|
wildcards.cards=cards
|
||||||
print(f"[cyan]cards file count : [/cyan]", len(wildcards.cards))
|
print(f"[cyan]cards file count : [/cyan]", len(wildcards.cards))
|
||||||
#print(f"cards : {cards.keys()}")
|
#print(f"cards : {cards.keys()}")
|
||||||
|
wildcards.is_card_Load=True
|
||||||
|
|
||||||
# 실행기
|
# 실행기
|
||||||
def run(text):
|
def run(text,load=False):
|
||||||
|
if text is None or type(text) is not str:
|
||||||
|
print("[red]text is not str : [/red]",text)
|
||||||
|
return None
|
||||||
|
if not wildcards.is_card_Load or load:
|
||||||
wildcards.card_load()
|
wildcards.card_load()
|
||||||
|
|
||||||
#print(f"text : {text}")
|
#print(f"text : {text}")
|
||||||
|
|||||||
Reference in New Issue
Block a user