bug fixs for various issues around module structure.
This commit is contained in:
+3
-3
@@ -25,13 +25,13 @@ from custom_nodes.EternalKernelLiteGraphNodes.image import Quantize
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import SelectFromRGBSimilarity
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import LoadImage
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import PromptTemplate
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import CodeExecWidget
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import ImageDistanceMask
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.image import TextRender
|
||||
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.functional import FuncBase
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.functional import FuncRender
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.functional import FuncRenderImage
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.functional import ExecWidget
|
||||
|
||||
if use_generic_nodes:
|
||||
NODE_CLASS_MAPPINGS_GENERIC = {
|
||||
@@ -48,7 +48,7 @@ if use_generic_nodes:
|
||||
"Quantize": Quantize,
|
||||
"Select From RGB Similarity": SelectFromRGBSimilarity,
|
||||
"Load Layered Image": LoadImage,
|
||||
"Code Execution Widget": CodeExecWidget,
|
||||
"Code Execution Widget": ExecWidget,
|
||||
"Image Distance Mask": ImageDistanceMask,
|
||||
|
||||
"Image Text": TextRender,
|
||||
@@ -76,7 +76,7 @@ else:
|
||||
"Select From RGB Similarity": SelectFromRGBSimilarity,
|
||||
"Load Layered Image": LoadImage,
|
||||
"Prompt Template": PromptTemplate,
|
||||
"Code Execution Widget": CodeExecWidget,
|
||||
"Code Execution Widget": ExecWidget,
|
||||
"Tiny Txt 2 Img": TinyTxtToImg,
|
||||
"Image Distance Mask": ImageDistanceMask,
|
||||
"Preview Image Test": PreviewImageTest,
|
||||
|
||||
+20
-19
@@ -1,3 +1,5 @@
|
||||
import hashlib
|
||||
|
||||
_func = {"func": ("FUNC",)}
|
||||
_text = {"code": ("STRING", {"multiline": True, "default": "y=x()"})}
|
||||
|
||||
@@ -23,10 +25,9 @@ class FuncBase:
|
||||
CATEGORY = "ETK/func"
|
||||
|
||||
def func(self, code: str, func: callable = lambda x: x):
|
||||
|
||||
globals = self.globals
|
||||
locals = self.locals
|
||||
locals["x"]=func
|
||||
locals["x"] = func
|
||||
# code should do something like:
|
||||
# func like : lambda x:["what"]*x
|
||||
# code like : 'f=[x for x in x(2)]'
|
||||
@@ -46,12 +47,12 @@ class FuncRender:
|
||||
use = required(both(_func, _text))
|
||||
return use
|
||||
|
||||
RETURN_TYPES = ("FLOAT","STRING","INT",)
|
||||
RETURN_TYPES = ("FLOAT", "STRING", "INT",)
|
||||
FUNCTION = "func"
|
||||
CATEGORY = "ETK/func"
|
||||
|
||||
def func(self, func: callable, code):
|
||||
y_float= None
|
||||
y_float = None
|
||||
y_string = None
|
||||
y_int = None
|
||||
|
||||
@@ -68,7 +69,7 @@ class FuncRender:
|
||||
self.globals = globals
|
||||
self.locals = locals
|
||||
|
||||
return (locals["y_float"],locals["y_string"],locals["y_int"],)
|
||||
return (locals["y_float"], locals["y_string"], locals["y_int"],)
|
||||
|
||||
|
||||
class FuncRenderImage:
|
||||
@@ -87,10 +88,9 @@ class FuncRenderImage:
|
||||
CATEGORY = "ETK/func"
|
||||
|
||||
def func(self, func: callable, code):
|
||||
|
||||
globals = self.globals
|
||||
locals = self.locals
|
||||
locals["x"]=func
|
||||
locals["x"] = func
|
||||
# code should do something like:
|
||||
# func like : lambda x:["what"]*x
|
||||
# code like : 'f=[x for x in x(2)]'
|
||||
@@ -100,7 +100,10 @@ class FuncRenderImage:
|
||||
|
||||
return (locals["y"],)
|
||||
|
||||
|
||||
class ExecWidget:
|
||||
import torch
|
||||
|
||||
"""runs eval on the given text"""
|
||||
|
||||
@classmethod
|
||||
@@ -117,15 +120,15 @@ class ExecWidget:
|
||||
"int1_in": ("INT", {"multiline": False}),
|
||||
|
||||
},
|
||||
"required": {
|
||||
# "text_to_eval": ("STRING",
|
||||
# {"multiline": True,
|
||||
# "default": "int_out=int_out\n"
|
||||
# "float_out=float_out\n"
|
||||
# "string_out=string_out\n"
|
||||
# "image_out=image_out\n"
|
||||
# }),
|
||||
}
|
||||
"required": {
|
||||
# "text_to_eval": ("STRING",
|
||||
# {"multiline": True,
|
||||
# "default": "int_out=int_out\n"
|
||||
# "float_out=float_out\n"
|
||||
# "string_out=string_out\n"
|
||||
# "image_out=image_out\n"
|
||||
# }),
|
||||
}
|
||||
}
|
||||
|
||||
CATEGORY = "text"
|
||||
@@ -192,7 +195,7 @@ class ExecWidget:
|
||||
|
||||
except Exception as e:
|
||||
string_obj = str(e)
|
||||
source_code=text_to_eval
|
||||
source_code = text_to_eval
|
||||
|
||||
string_obj = new_locals.get("string_out", string_obj)
|
||||
image_obj = new_locals.get("image_out", image_obj)
|
||||
@@ -200,7 +203,6 @@ class ExecWidget:
|
||||
int_obj = new_locals.get("int_out", int_obj)
|
||||
tuple_obj = new_locals.get("tuple_out", tuple_obj)
|
||||
|
||||
|
||||
return (string_obj, image_obj, float_obj, int_obj, tuple_obj, text_to_eval)
|
||||
|
||||
@classmethod
|
||||
@@ -216,4 +218,3 @@ if __name__ == "__main__":
|
||||
test = {}
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -131,7 +131,9 @@ def torch_image_show(image):
|
||||
|
||||
class TinyTxtToImg:
|
||||
"""small text to image generator"""
|
||||
|
||||
share_clip = None
|
||||
share_mdl = None
|
||||
share_vae = None
|
||||
def __init__(self):
|
||||
import random
|
||||
self.mdl = None
|
||||
@@ -152,6 +154,7 @@ class TinyTxtToImg:
|
||||
self.latent_image = None
|
||||
self.samples = None
|
||||
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {"required":
|
||||
@@ -161,6 +164,8 @@ class TinyTxtToImg:
|
||||
"clip_encoder": (["comfy -ignore below", "advanced"],),
|
||||
"token_normalization": (["none", "mean", "length", "length+mean"],),
|
||||
"weight_interpretation": (["comfy", "A1111", "compel", "comfy++"],),
|
||||
"ckpt_name": (folder_paths.get_filename_list("checkpoints"),),
|
||||
|
||||
|
||||
},
|
||||
"optional": {
|
||||
@@ -182,30 +187,34 @@ class TinyTxtToImg:
|
||||
clip_encoder="comfy -ignore below",
|
||||
token_normalization="length+mean",
|
||||
weight_interpretation="comfy++",
|
||||
FUNC: callable = None):
|
||||
FUNC: callable = None,
|
||||
ckpt_name="v1-5-pruned-emaonly.safetensors",
|
||||
):
|
||||
""" use the imports from nodes to generate an image from text """
|
||||
|
||||
import random
|
||||
import json
|
||||
|
||||
if not hasattr(CheckpointLoaderSimple, "share_mdl"):
|
||||
CheckpointLoaderSimple.share_mdl = None
|
||||
if not hasattr( TinyTxtToImg, "share_mdl"):
|
||||
TinyTxtToImg.share_mdl = None
|
||||
|
||||
if CheckpointLoaderSimple.share_mdl is None:
|
||||
self.mdl, self.clp, self.vae, self.vision = CheckpointLoaderSimple.load_checkpoint(None,
|
||||
ckpt_name="v1-5-pruned-emaonly.safetensors"
|
||||
)
|
||||
CSL = CheckpointLoaderSimple
|
||||
if TinyTxtToImg.share_mdl is None:
|
||||
self.mdl, self.clp, self.vae, self.vision = \
|
||||
CheckpointLoaderSimple.load_checkpoint(None,
|
||||
ckpt_name=ckpt_name
|
||||
)
|
||||
CSL = TinyTxtToImg
|
||||
CSL.share_mdl = self.mdl
|
||||
CSL.share_clip = self.clp
|
||||
CSL.share_vae = self.vae
|
||||
CSL.share_vision = self.vision
|
||||
|
||||
else:
|
||||
self.mdl, self.clp, self.vae = (CheckpointLoaderSimple.share_mdl,
|
||||
CheckpointLoaderSimple.share_clip,
|
||||
CheckpointLoaderSimple.share_vae
|
||||
self.mdl, self.clp, self.vae = (TinyTxtToImg.share_mdl,
|
||||
TinyTxtToImg.share_clip,
|
||||
TinyTxtToImg.share_vae
|
||||
)
|
||||
|
||||
self.seed = random.randint(0, 2 ** 32 - 1)
|
||||
self.steps = 10
|
||||
self.cfg = 8
|
||||
@@ -1273,8 +1282,13 @@ class KSampler:
|
||||
|
||||
def sample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=1.0,
|
||||
one_seed_per_batch=False):
|
||||
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|
||||
denoise=denoise, one_seed_per_batch=one_seed_per_batch)
|
||||
try:
|
||||
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|
||||
denoise=denoise,one_seed_per_batch=one_seed_per_batch)
|
||||
except TypeError as e:
|
||||
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
|
||||
denoise=denoise)
|
||||
|
||||
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
Reference in New Issue
Block a user