Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
026ffb291b | ||
|
|
038ea91985 | ||
|
|
fe13add535 | ||
|
|
40ad60ab06 | ||
|
|
41be495672 | ||
|
|
059d59455c | ||
|
|
99a74bee92 | ||
|
|
3247eaec7e | ||
|
|
dd3420d15c | ||
|
|
eb17b381a6 | ||
|
|
6feccddcba | ||
|
|
7bd85c9544 | ||
|
|
01590a7839 | ||
|
|
cf91e6a57a | ||
|
|
1e7442625b | ||
|
|
f8863c5cb2 | ||
|
|
222c0b2c65 | ||
|
|
9c8ecab6fc | ||
|
|
a5e946261e | ||
|
|
37851ff4ce | ||
|
|
3472043e28 | ||
|
|
f7d40d0b2d | ||
|
|
98ae062bc0 | ||
|
|
f4d889bc74 | ||
|
|
61c0536251 | ||
|
|
fabcf37fb3 | ||
|
|
67dce2659e | ||
|
|
4596db540c |
@@ -18,13 +18,71 @@ 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"
|
||||
|
||||
CATEGORY = "conditioning"
|
||||
|
||||
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:
|
||||
@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)
|
||||
print(f"[green]text : [/green]",text)
|
||||
r=wildcards.run(text)
|
||||
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), {}]], )
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import os
|
||||
import comfy.sd
|
||||
from nodes import *
|
||||
import folder_paths
|
||||
import random
|
||||
from .check_name import *
|
||||
from folder_paths import *
|
||||
import random
|
||||
import os
|
||||
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:
|
||||
from .ConsoleColor import print, console
|
||||
from .ConsoleColor import print, console, ccolor
|
||||
from .mypath import *
|
||||
|
||||
#print(__file__)
|
||||
#print(os.path.basename(__file__))
|
||||
@@ -34,15 +35,13 @@ class CheckpointLoaderSimpleText:
|
||||
CATEGORY = "loaders"
|
||||
|
||||
def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True):
|
||||
ckpt_path =check_name_ckpt(name_split_choice(ckpt_name))
|
||||
if ckpt_path is None:
|
||||
print(f"{ckpt_name} is none")
|
||||
return
|
||||
print(f"[{ccolor}]ckpt_name : [/{ccolor}]", ckpt_name)
|
||||
ckpt_path=getFullPath(ckpt_name,"checkpoints")
|
||||
try:
|
||||
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
|
||||
except Exception as e:
|
||||
print("CheckpointLoaderSimpleText Exception : "+ e)
|
||||
console.print_exception()
|
||||
return
|
||||
|
||||
|
||||
|
||||
+10
-1
@@ -12,8 +12,17 @@ if missing:
|
||||
subprocess.check_call([python, '-m', 'pip', 'install', *missing], stdout=subprocess.DEVNULL)
|
||||
|
||||
from rich.console import Console
|
||||
console=Console()
|
||||
from rich.theme import Theme
|
||||
#console=Console(style="reset")
|
||||
custom_theme = Theme({
|
||||
"repr.path": "bright_blue",
|
||||
"progress.percentage": "bright_blue",
|
||||
"markdown.block_quote": "bright_blue",
|
||||
"iso8601.time": "bright_blue"
|
||||
})
|
||||
console = Console(theme=custom_theme)
|
||||
print=console.log
|
||||
ccolor="bright_yellow"
|
||||
"""
|
||||
print("test", style="bold white on blue")
|
||||
print("test", style="bold green")
|
||||
|
||||
+11
-17
@@ -4,9 +4,11 @@ from nodes import *
|
||||
import folder_paths
|
||||
|
||||
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:
|
||||
from .ConsoleColor import print, console
|
||||
from .ConsoleColor import print, console, ccolor
|
||||
from .mypath import *
|
||||
|
||||
class LoraLoaderText:
|
||||
@classmethod
|
||||
@@ -31,23 +33,15 @@ class LoraLoaderText:
|
||||
|
||||
def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
|
||||
|
||||
if lora_name is None or lora_name =="":
|
||||
print(f"[{ccolor}]lora_name : [/{ccolor}]", 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)
|
||||
return (model, clip)
|
||||
|
||||
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)
|
||||
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:
|
||||
model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora_path, strength_model, strength_clip)
|
||||
return (model_lora, clip_lora)
|
||||
|
||||
@@ -3,7 +3,12 @@ import comfy.sd
|
||||
from nodes import *
|
||||
import folder_paths
|
||||
import random
|
||||
from .check_name import *
|
||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||
from ConsoleColor import print, console
|
||||
from mypath import *
|
||||
else:
|
||||
from .ConsoleColor import print, console
|
||||
from .mypath import *
|
||||
|
||||
class LoraLoaderTextRandom:
|
||||
@classmethod
|
||||
|
||||
@@ -70,20 +70,49 @@ c
|
||||
__anotherfile__
|
||||
```
|
||||
|
||||
### reload card
|
||||
|
||||
call wildcards.card_load()
|
||||
or
|
||||
wildcards.run("{9$$-$$a|b|c}",True)
|
||||
|
||||
## for ComfyUI
|
||||
|
||||
|
||||
|
||||
### CLIPTextEncodeWildcards
|
||||
|
||||
- CLIPTextEncodeWildcards : no seed
|
||||
- CLIPTextEncodeWildcards : seed
|
||||
|
||||

|
||||
|
||||
|
||||
### SimpleSampler+modelVAE
|
||||
|
||||
- include wildcards
|
||||
|
||||

|
||||
|
||||
|
||||
### SimpleSampler
|
||||
|
||||
- include wildcards
|
||||
|
||||

|
||||
|
||||
|
||||
### SimpleSamplerVAE
|
||||
|
||||
## random_sampler_node.py
|
||||
- include wildcards
|
||||
|
||||

|
||||
|
||||
|
||||
### random_sampler_node.py
|
||||
|
||||

|
||||
|
||||
## VAELoaderDecode.py
|
||||
### VAELoaderDecode.py
|
||||
|
||||

|
||||
|
||||
+115
-22
@@ -2,7 +2,7 @@ import comfy.samplers
|
||||
import comfy.sd
|
||||
import comfy.utils
|
||||
|
||||
import comfy_extras.clip_vision
|
||||
#import comfy_extras.clip_vision
|
||||
|
||||
import model_management
|
||||
import importlib
|
||||
@@ -17,7 +17,9 @@ import hashlib
|
||||
import copy
|
||||
import traceback
|
||||
|
||||
|
||||
from PIL import Image
|
||||
from nodes import common_ksampler
|
||||
from PIL.PngImagePlugin import PngInfo
|
||||
import numpy as np
|
||||
|
||||
@@ -25,10 +27,12 @@ import numpy as np
|
||||
#print(f"SimpleSampler __file__ {os.path.splitext(os.path.basename(__file__))[0]}")
|
||||
|
||||
import os
|
||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||
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
|
||||
#print(__file__)
|
||||
#print(os.path.basename(__file__))
|
||||
|
||||
@@ -46,6 +50,46 @@ except:
|
||||
err_msg = traceback.format_exc()
|
||||
print(err_msg)
|
||||
|
||||
|
||||
def encode(clip, text):
|
||||
if wildcardsOn:
|
||||
text=wildcards.run(text)
|
||||
return [[clip.encode(text), {}]]
|
||||
|
||||
def generate(width, height, batch_size=1):
|
||||
latent = torch.zeros([batch_size, 4, height // 8, width // 8])
|
||||
return {"samples":latent}
|
||||
# RETURN_TYPES = ("LATENT",)
|
||||
|
||||
def decode(vae, samples):
|
||||
return vae.decode(samples["samples"])
|
||||
# RETURN_TYPES = ("IMAGE",)
|
||||
|
||||
def sample(
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
clip,
|
||||
vae,
|
||||
positive, negative,
|
||||
#latent_image,
|
||||
width, height, denoise=1.0, batch_size=1
|
||||
):
|
||||
|
||||
samples=common_ksampler(
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
#positive,
|
||||
encode(clip, positive),
|
||||
#negative,
|
||||
encode(clip, negative),
|
||||
#latent_image,
|
||||
generate( width, height, batch_size=1),
|
||||
denoise=denoise)[0]
|
||||
|
||||
return (decode(vae,samples),)
|
||||
|
||||
def load_vae(vae_name):
|
||||
vae_path = folder_paths.get_full_path("vae", vae_name)
|
||||
vae = comfy.sd.VAE(ckpt_path=vae_path)
|
||||
return vae
|
||||
#----------------------------
|
||||
class SimpleSampler:
|
||||
@classmethod
|
||||
@@ -54,39 +98,88 @@ class SimpleSampler:
|
||||
{
|
||||
"model": ("MODEL",),
|
||||
#"positive": ("CONDITIONING", ),
|
||||
"positive": ("STRING", {"multiline": True}), "clip": ("CLIP", ),
|
||||
"clip": ("CLIP", ),
|
||||
"vae": ("VAE", ),
|
||||
"positive": ("STRING", {"multiline": True}),
|
||||
#"negative": ("CONDITIONING", ),
|
||||
"negative": ("STRING", {"multiline": True}), "clip": ("CLIP", ),
|
||||
"negative": ("STRING", {"multiline": True}),
|
||||
"width": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"height": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"batch_size": ("INT", {"default": 1, "min": 1, "max": 64}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
|
||||
"cfg": ("FLOAT", {"default": 3.0, "min": 0.0, "max": 100.0}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
|
||||
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, ),
|
||||
"latent_image": ("LATENT", ),
|
||||
#"latent_image": ("LATENT", ),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
}}
|
||||
|
||||
RETURN_TYPES = ("LATENT",)
|
||||
FUNCTION = "sample"
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
#RETURN_TYPES = ("LATENT",)
|
||||
FUNCTION = "simple"
|
||||
|
||||
CATEGORY = "sampling"
|
||||
|
||||
def encode(self, clip, text):
|
||||
if wildcardsOn:
|
||||
text=wildcards.run(text)
|
||||
return ([[clip.encode(text), {}]], )
|
||||
|
||||
def generate(self, width, height, batch_size=1):
|
||||
latent = torch.zeros([batch_size, 4, height // 8, width // 8])
|
||||
return ({"samples":latent}, )
|
||||
|
||||
def sample(self,
|
||||
model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|
||||
def simple(self,
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
clip,
|
||||
vae,
|
||||
positive, negative,
|
||||
width, height, denoise=1.0, batch_size=1
|
||||
):
|
||||
|
||||
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, self.encode(clip, positive), elf.encode(clip, negative), self.generate( width, height, batch_size=1), denoise=denoise)
|
||||
|
||||
return sample(
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
clip,
|
||||
vae,
|
||||
positive, negative,
|
||||
width, height, denoise, batch_size
|
||||
)
|
||||
|
||||
#----------------------------
|
||||
class SimpleSamplerVAE:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {"required":
|
||||
{
|
||||
"model": ("MODEL",),
|
||||
#"positive": ("CONDITIONING", ),
|
||||
"clip": ("CLIP", ),
|
||||
#"vae": ("VAE", ),
|
||||
"vae_name": (folder_paths.get_filename_list("vae"), ),
|
||||
"positive": ("STRING", {"multiline": True}),
|
||||
#"negative": ("CONDITIONING", ),
|
||||
"negative": ("STRING", {"multiline": True}),
|
||||
"width": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"height": ("INT", {"default": 512, "min": 64, "max": 4096, "step": 64}),
|
||||
"batch_size": ("INT", {"default": 1, "min": 1, "max": 64}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
|
||||
"cfg": ("FLOAT", {"default": 3.0, "min": 0.0, "max": 100.0}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
|
||||
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, ),
|
||||
#"latent_image": ("LATENT", ),
|
||||
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
||||
}}
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
#RETURN_TYPES = ("LATENT",)
|
||||
FUNCTION = "simple"
|
||||
|
||||
CATEGORY = "sampling"
|
||||
|
||||
def simple(self,
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
clip,
|
||||
vae_name,
|
||||
positive, negative,
|
||||
width, height, denoise=1.0, batch_size=1
|
||||
):
|
||||
|
||||
return sample(
|
||||
model, seed, steps, cfg, sampler_name, scheduler,
|
||||
clip,
|
||||
load_vae(vae_name),
|
||||
positive, negative,
|
||||
width, height, denoise, batch_size
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
+52
-19
@@ -1,9 +1,24 @@
|
||||
import sys
|
||||
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
|
||||
#md="custom_nodes.ComfyUI_node_Lilly."
|
||||
else:
|
||||
from .ConsoleColor import print, console
|
||||
#md="custom_nodes.ComfyUI_node_Lilly."
|
||||
md="custom_nodes.ComfyUI_node_Lilly."
|
||||
#print(__file__)
|
||||
#print(os.path.basename(__file__))
|
||||
|
||||
@@ -21,13 +36,14 @@ else:
|
||||
#path, filename = os.path.split(absFilePath)
|
||||
#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)
|
||||
|
||||
md=nm.replace(wd+"\\","")
|
||||
#print("abspath __name__ : ", nm)
|
||||
#
|
||||
#md=nm.replace(wd+"\\","")
|
||||
#print("import name", md)
|
||||
"""
|
||||
"""
|
||||
@@ -35,35 +51,52 @@ md=nm.replace(wd+"\\","")
|
||||
# print(f"{md!r} already in sys.modules")
|
||||
#else:
|
||||
# print(f"{md!r} not in sys.modules")
|
||||
|
||||
if not md.startswith("custom_nodes."):
|
||||
|
||||
import importlib
|
||||
#from custom_nodes.ComfyUI_node_Lilly import eval(f"{name}")
|
||||
#import importlib
|
||||
#import ComfyUI_node_Lilly
|
||||
#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 = {
|
||||
}
|
||||
|
||||
def add(name):
|
||||
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}")
|
||||
#pkg = importlib.import_module(f"{md}{name}")
|
||||
#eval(f"{md}{name}")
|
||||
exec(f"import {md}{name}")
|
||||
if clist is None:
|
||||
NODE_CLASS_MAPPINGS[name]=eval(f"{md}{name}.{name}")
|
||||
elif type(clist) is str:
|
||||
NODE_CLASS_MAPPINGS[clist]=eval(f"{md}{name}.{clist}")
|
||||
elif type(clist) is list:
|
||||
for c in clist:
|
||||
NODE_CLASS_MAPPINGS[c]=eval(f"{md}{name}.{c}")
|
||||
|
||||
print(f"Load ok : {name}", style="bold green")
|
||||
except Exception:
|
||||
console.print_exception()
|
||||
|
||||
|
||||
console.rule(f" init start ", style="bold green")
|
||||
|
||||
|
||||
add("CheckpointLoaderRandom")
|
||||
add("CheckpointLoaderSimpleText")
|
||||
add("CLIPTextEncodeWildcards")
|
||||
add("CLIPTextEncodeWildcards",["CLIPTextEncodeWildcards","CLIPTextEncodeWildcards2","CLIPTextEncodeWildcards3"])
|
||||
add("LoraLoaderText")
|
||||
add("LoraLoaderTextRandom")
|
||||
add("Random_Sampler")
|
||||
add("VAELoaderDecode")
|
||||
add("SimpleSampler")
|
||||
add("VAELoaderText")
|
||||
add("SimpleSampler",["SimpleSampler","SimpleSamplerVAE"])
|
||||
add("SaveImageSimple")
|
||||
add("TextWildcards")
|
||||
#add("test")
|
||||
|
||||
console.rule(" finit end ", style="bold green")
|
||||
|
||||
console.rule(" init end ", style="bold green")
|
||||
@@ -1,25 +0,0 @@
|
||||
import os
|
||||
from folder_paths import supported_ckpt_extensions,supported_pt_extensions
|
||||
import folder_paths
|
||||
import random
|
||||
|
||||
def check_name(kind,name,supported_extensions):
|
||||
for ext in supported_extensions:
|
||||
if name.lower().endswith(ext):
|
||||
path = folder_paths.get_full_path(kind, name)
|
||||
if path is not None:
|
||||
return path
|
||||
|
||||
for ext in supported_extensions:
|
||||
path = folder_paths.get_full_path(kind, name+ext)
|
||||
if path is not None:
|
||||
return path
|
||||
|
||||
def check_name_ckpt(name):
|
||||
return check_name("checkpoints",name,supported_ckpt_extensions)
|
||||
|
||||
def check_name_pt(kind,name):
|
||||
return check_name(kind,name,supported_pt_extensions)
|
||||
|
||||
def name_split_choice(name):
|
||||
return random.choice(name.split('|'))
|
||||
@@ -1,13 +1,13 @@
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import ast
|
||||
import os, glob
|
||||
import random
|
||||
from folder_paths import *
|
||||
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
|
||||
@@ -48,22 +48,65 @@ print("os.path.abspath(sys.modules\['__main__'].__file__) : " + mainFile ,style=
|
||||
mainfolder = os.path.dirname(mainFile)
|
||||
print("os.path.dirname(mainFile) : " + mainfolder , style="bold CYAN")
|
||||
|
||||
def jsondic(full,dic,update=False):
|
||||
def check_name(kind,name,supported_extensions):
|
||||
for ext in supported_extensions:
|
||||
if name.lower().endswith(ext):
|
||||
path = folder_paths.get_full_path(kind, name)
|
||||
if path is not None:
|
||||
return path
|
||||
|
||||
for ext in supported_extensions:
|
||||
path = folder_paths.get_full_path(kind, name+ext)
|
||||
if path is not None:
|
||||
return path
|
||||
|
||||
def check_name_ckpt(name):
|
||||
return check_name("checkpoints",name,supported_ckpt_extensions)
|
||||
|
||||
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)
|
||||
def check_name_pt(kind,name):
|
||||
return check_name(kind,name,supported_pt_extensions)
|
||||
|
||||
def name_split_choice(name):
|
||||
return random.choice(name.split('|'))
|
||||
|
||||
#----------------------
|
||||
|
||||
def filenameget(v_path):
|
||||
t_path=os.path.join(os.path.dirname(__file__),v_path)
|
||||
print(t_path)
|
||||
fullpaths=glob.glob(t_path, recursive=True)
|
||||
print(fullpaths)
|
||||
fullpath=random.choice(fullpaths)
|
||||
name=os.path.basename(fullpath)
|
||||
#r_path=[os.path.basename(fullpath) for fullpath in fullpaths]
|
||||
return (name,fullpath)
|
||||
|
||||
# "test","vae",["pt","safetensors"]
|
||||
def getFullPath(p,k,el=["safetensors","ckpt","pt"]):
|
||||
if os.path.isabs(p):
|
||||
path=p
|
||||
else:
|
||||
with open(full, 'w', encoding='utf-8') as file:
|
||||
json.dump(dic, file, sort_keys=False, indent=4)
|
||||
|
||||
return path
|
||||
|
||||
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
|
||||
+27
-16
@@ -2,10 +2,10 @@ import glob, sys
|
||||
import random
|
||||
import re
|
||||
import os
|
||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] :
|
||||
from ConsoleColor import print, console
|
||||
if __name__ == os.path.splitext(os.path.basename(__file__))[0] or __name__ =='__main__':
|
||||
from ConsoleColor import print, console, ccolor
|
||||
else:
|
||||
from .ConsoleColor import print, console
|
||||
from .ConsoleColor import print, console , ccolor
|
||||
#print(__file__)
|
||||
#print(os.path.basename(__file__))
|
||||
#print(os.getcwd())
|
||||
@@ -20,10 +20,12 @@ class wildcards:
|
||||
|
||||
# 정규식
|
||||
#resub = re.compile(r"(\{)([^\{\}]*)(\})")
|
||||
resub = re.compile(r"(\{)(((\d+)|(\d+)?-(\d+)?)?\$\$)?([^\{\}]*)(\})")
|
||||
#resub = re.compile(r"(\{)(((\d+)|(\d+)?-(\d+)?)?\$\$((.*)?\$\$)?)?([^\{\}]*)(\})")
|
||||
resub = re.compile(r"(\{)(((\d+)|(\d+)?-(\d+)?)?\$\$(([^\{\}]*?)\$\$)?)?([^\{\}]*)(\})")
|
||||
recard = re.compile(r"(__)(.*?)(__)")
|
||||
|
||||
# 카드 목록
|
||||
is_card_Load = False
|
||||
cards = {}
|
||||
seperator=", "
|
||||
loop_max=50
|
||||
@@ -33,17 +35,20 @@ class wildcards:
|
||||
#print(f"sub : {(match.groups())}")
|
||||
try:
|
||||
#m=match.group(2)
|
||||
seperator=wildcards.seperator
|
||||
s=match.group(3)
|
||||
m=match.group(7).split("|")
|
||||
|
||||
#print(f"m : {m}")
|
||||
m=match.group(9).split("|")
|
||||
p=match.group(8)
|
||||
if p:
|
||||
seperator=p
|
||||
|
||||
if s is None:
|
||||
return random.choice(m)
|
||||
c=len(m)
|
||||
n=int(match.group(4)) if match.group(4) else None
|
||||
if n:
|
||||
|
||||
r=wildcards.seperator.join(random.sample(m,min(n,c)))
|
||||
r=seperator.join(random.sample(m,min(n,c)))
|
||||
#print(f"n : {n} ; {r}")
|
||||
return r
|
||||
|
||||
@@ -54,7 +59,7 @@ class wildcards:
|
||||
a=min(int(n1 if n1 else c), int(n2 if n2 else c),c)
|
||||
b=min(max(int(n1 if n1 else 0), int(n2 if n2 else 0)),c)
|
||||
#print(f"ab : {a} ; {b}")
|
||||
r=wildcards.seperator.join(
|
||||
r=seperator.join(
|
||||
random.sample(
|
||||
m,
|
||||
random.randint(
|
||||
@@ -65,7 +70,7 @@ class wildcards:
|
||||
#n1=int(match.group(5)) if not match.group(5) is None
|
||||
#n2=int(match.group(6)) if not match.group(6) is None
|
||||
else:
|
||||
r=wildcards.seperator.join(
|
||||
r=seperator.join(
|
||||
random.sample(
|
||||
m,
|
||||
random.randint(
|
||||
@@ -148,11 +153,15 @@ class wildcards:
|
||||
wildcards.cards=cards
|
||||
print(f"[cyan]cards file count : [/cyan]", len(wildcards.cards))
|
||||
#print(f"cards : {cards.keys()}")
|
||||
wildcards.is_card_Load=True
|
||||
|
||||
# 실행기
|
||||
def run(text):
|
||||
|
||||
wildcards.card_load()
|
||||
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()
|
||||
|
||||
#print(f"text : {text}")
|
||||
result=wildcards.card_loop(text)
|
||||
@@ -166,7 +175,9 @@ 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|}/{9$$-$$a|b|c}/{9$$ {and|or} $$a|b|c}"
|
||||
print("[green]wildcards test : [/green]",wildcards.run(test),style="reset")
|
||||
#print("wildcards test : "+wildcards.run("{9$$a|b}"))
|
||||
print("[green]wildcards test : [/green]",wildcards.run("__my__"))
|
||||
#print("[green]wildcards test : [/green]",wildcards.run("__my__"))
|
||||
print("wildcards test : "+wildcards.run("{9$$-$$a|b|c}"))
|
||||
print("wildcards test : "+wildcards.run("{9$$ {and|or} $$a|b|c}"))
|
||||
|
||||
Reference in New Issue
Block a user