diff --git a/CheckpointLoaderSimpleText.py b/CheckpointLoaderSimpleText.py index 4fce737..9621667 100644 --- a/CheckpointLoaderSimpleText.py +++ b/CheckpointLoaderSimpleText.py @@ -48,7 +48,7 @@ class CheckpointLoaderSimpleText: else: (name,fullpath)=filenameget(os.path.join(models_dir, "checkpoints")+"/**/"+ckpt_name+"*.safetensors") if fullpath is None: - print(f"{name} is none") + print(f"{ckpt_name} is none") return ckpt_path=fullpath try: diff --git a/VAELoaderText.py b/VAELoaderText.py new file mode 100644 index 0000000..a23a229 --- /dev/null +++ b/VAELoaderText.py @@ -0,0 +1,45 @@ +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 + from mypath import * +else: + from .ConsoleColor import print, console + 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): + if os.path.isabs(vae_name): + vae_path=vae_name + else: + if vae_name.endswith('.safetensors') or vae_name.endswith('.pt') : + vae_path = folder_paths.get_full_path("vae", vae_name) + if vae_path is None: + print(f"{vae_name} is none") + if vae_name.endswith(".safetensors") or vae_name.endswith(".pt"): + (name,fullpath)=filenameget(os.path.join(models_dir, "vae")+"/**/"+vae_name) + else: + (name,fullpath)=filenameget(os.path.join(models_dir, "vae")+"/**/"+vae_name+"*.safetensors") + if fullpath is None: + print(f"{vae_name} is none") + return + vae_path=fullpath + + vae = comfy.sd.VAE(ckpt_path=vae_path) + return (vae,) \ No newline at end of file diff --git a/__init__.py b/__init__.py index 7b81146..1c31088 100644 --- a/__init__.py +++ b/__init__.py @@ -93,6 +93,7 @@ if __name__ == "ComfyUI_node_Lilly" : add("LoraLoaderTextRandom") add("Random_Sampler") add("VAELoaderDecode") + add("VAELoaderText") add("SimpleSampler",["SimpleSampler","SimpleSamplerVAE"]) add("SaveImageSimple") add("TextWildcards")