From fb288e4eaf857572440a43fc2bf47253d8175cf7 Mon Sep 17 00:00:00 2001 From: wallish77 Date: Mon, 21 Aug 2023 20:16:32 -0500 Subject: [PATCH] fixed image preview on save, added workflow example --- basic-workflow-wlsh.json | 1268 ++++++++++++++++++++++++++++++++++++++ wlsh_nodes.py | 24 +- 2 files changed, 1286 insertions(+), 6 deletions(-) create mode 100644 basic-workflow-wlsh.json diff --git a/basic-workflow-wlsh.json b/basic-workflow-wlsh.json new file mode 100644 index 0000000..88e0ab7 --- /dev/null +++ b/basic-workflow-wlsh.json @@ -0,0 +1,1268 @@ +{ + "last_node_id": 40, + "last_link_id": 68, + "nodes": [ + { + "id": 34, + "type": "PrimitiveNode", + "pos": [ + 461, + 51 + ], + "size": [ + 655.8297500610352, + 137.63140869140625 + ], + "flags": {}, + "order": 0, + "mode": 0, + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [ + 51, + 64 + ], + "slot_index": 0, + "widget": { + "name": "text", + "config": [ + "STRING", + { + "multiline": true + } + ] + }, + "label": "positive" + } + ], + "title": "Positive (Primitive)", + "properties": {}, + "widgets_values": [ + "acrylic sticker of a bowl of spaghetti, vector art" + ] + }, + { + "id": 28, + "type": "Image Save with Prompt Data (WLSH)", + "pos": [ + 1896, + 55 + ], + "size": [ + 364, + 567 + ], + "flags": {}, + "order": 19, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 54 + }, + { + "name": "info", + "type": "INFO", + "link": 50 + }, + { + "name": "positive", + "type": "STRING", + "link": 64, + "widget": { + "name": "positive", + "config": [ + "STRING", + { + "default": "", + "multiline": true, + "hideWidget": true + } + ] + } + }, + { + "name": "negative", + "type": "STRING", + "link": 65, + "widget": { + "name": "negative", + "config": [ + "STRING", + { + "default": "", + "multiline": true + } + ] + } + }, + { + "name": "seed", + "type": "INT", + "link": 68, + "widget": { + "name": "seed", + "config": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709552000 + } + ] + } + }, + { + "name": "modelname", + "type": "STRING", + "link": 46, + "widget": { + "name": "modelname", + "config": [ + "STRING", + { + "default": "", + "multiline": false + } + ] + } + }, + { + "name": "time_format", + "type": "STRING", + "link": 45, + "widget": { + "name": "time_format", + "config": [ + "STRING", + { + "default": "%Y-%m-%d-%H%M%S", + "multiline": false + } + ] + } + }, + { + "name": "counter", + "type": "INT", + "link": 67, + "widget": { + "name": "counter", + "config": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709552000 + } + ] + } + } + ], + "properties": { + "Node name for S&R": "Image Save with Prompt Data (WLSH)" + }, + "widgets_values": [ + "%time_%seed", + "tmp", + "png", + 100, + "acrylic sticker of a bowl of spaghetti, vector art", + "photo", + 550413295226012, + "randomize", + "", + 0, + "%Y-%m-%d-%H%M%S" + ] + }, + { + "id": 30, + "type": "CLIPTextEncode", + "pos": [ + 701, + 428 + ], + "size": [ + 210, + 62 + ], + "flags": { + "collapsed": true + }, + "order": 13, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 43 + }, + { + "name": "text", + "type": "STRING", + "link": 51, + "widget": { + "name": "text", + "config": [ + "STRING", + { + "multiline": true + } + ] + } + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 60 + ], + "shape": 3 + } + ], + "title": "Positive Encode", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "acrylic sticker of a bowl of spaghetti, vector art" + ] + }, + { + "id": 35, + "type": "CLIPTextEncode", + "pos": [ + 700, + 475 + ], + "size": { + "0": 210, + "1": 62 + }, + "flags": { + "collapsed": true + }, + "order": 14, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 53 + }, + { + "name": "text", + "type": "STRING", + "link": 52, + "widget": { + "name": "text", + "config": [ + "STRING", + { + "multiline": true + } + ] + } + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 61 + ], + "shape": 3 + } + ], + "title": "Negative Encode", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "photo" + ] + }, + { + "id": 29, + "type": "KSamplerAdvanced (WLSH)", + "pos": [ + 872, + 420 + ], + "size": [ + 315, + 542 + ], + "flags": {}, + "order": 16, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 42 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 60, + "slot_index": 1 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 61, + "slot_index": 2 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 59 + }, + { + "name": "seed", + "type": "INT", + "link": 58, + "widget": { + "name": "seed", + "config": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709552000 + } + ] + } + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 49 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "INFO", + "type": "INFO", + "links": [ + 50 + ], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "KSamplerAdvanced (WLSH)" + }, + "widgets_values": [ + "enable", + 384922404539374, + "randomize", + 20, + 8, + "euler", + "normal", + 0, + 10000, + "disable", + 1 + ] + }, + { + "id": 31, + "type": "Time String (WLSH)", + "pos": [ + 1609, + -176 + ], + "size": [ + 250, + 58 + ], + "flags": {}, + "order": 1, + "mode": 0, + "outputs": [ + { + "name": "time_format", + "type": "STRING", + "links": [ + 45 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "Time String (WLSH)" + }, + "widgets_values": [ + "%Y-%m-%d-%H%M%S" + ] + }, + { + "id": 40, + "type": "PrimitiveNode", + "pos": [ + 1620, + -76 + ], + "size": { + "0": 210, + "1": 82 + }, + "flags": {}, + "order": 2, + "mode": 0, + "outputs": [ + { + "name": "INT", + "type": "INT", + "links": [ + 67 + ], + "slot_index": 0, + "widget": { + "name": "seed", + "config": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709552000 + } + ] + }, + "label": "seed" + } + ], + "title": "Counter (Primitive)", + "properties": {}, + "widgets_values": [ + 1, + "increment" + ] + }, + { + "id": 10, + "type": "PreviewImage", + "pos": [ + 1218, + 65 + ], + "size": [ + 654.8297424316406, + 597.6314086914062 + ], + "flags": {}, + "order": 20, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 62 + } + ], + "properties": { + "Node name for S&R": "PreviewImage" + } + }, + { + "id": 32, + "type": "Upscale by Factor with Model (WLSH)", + "pos": [ + 1483, + 710 + ], + "size": { + "0": 315, + "1": 102 + }, + "flags": {}, + "order": 18, + "mode": 0, + "inputs": [ + { + "name": "upscale_model", + "type": "UPSCALE_MODEL", + "link": 47 + }, + { + "name": "image", + "type": "IMAGE", + "link": 48 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 54, + 62 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "Upscale by Factor with Model (WLSH)" + }, + "widgets_values": [ + "nearest-exact", + 2 + ] + }, + { + "id": 8, + "type": "VAEDecode", + "pos": [ + 1254, + 728 + ], + "size": { + "0": 210, + "1": 46 + }, + "flags": { + "collapsed": true + }, + "order": 17, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 49 + }, + { + "name": "vae", + "type": "VAE", + "link": 19 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 48 + ], + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + } + }, + { + "id": 39, + "type": "PrimitiveNode", + "pos": [ + 473, + 411 + ], + "size": { + "0": 210, + "1": 82 + }, + "flags": {}, + "order": 3, + "mode": 0, + "outputs": [ + { + "name": "INT", + "type": "INT", + "links": [ + 58, + 68 + ], + "slot_index": 0, + "widget": { + "name": "seed", + "config": [ + "INT", + { + "default": 0, + "min": 0, + "max": 18446744073709552000 + } + ] + }, + "label": "seed" + } + ], + "title": "Seed (Primitive)", + "properties": {}, + "widgets_values": [ + 239905076771700, + "randomize" + ] + }, + { + "id": 13, + "type": "Reroute", + "pos": [ + 348, + -56 + ], + "size": [ + 82, + 26 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 38 + } + ], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 42 + ], + "slot_index": 0 + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 15, + "type": "Reroute", + "pos": [ + 607, + -55 + ], + "size": [ + 75, + 26 + ], + "flags": {}, + "order": 11, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 39 + } + ], + "outputs": [ + { + "name": "VAE", + "type": "VAE", + "links": [ + 19 + ], + "slot_index": 0 + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 14, + "type": "Reroute", + "pos": [ + 483, + -63 + ], + "size": [ + 75, + 26 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "name": "", + "type": "*", + "link": 40 + } + ], + "outputs": [ + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 43, + 53 + ], + "slot_index": 0 + } + ], + "properties": { + "showOutputText": true, + "horizontal": false + } + }, + { + "id": 26, + "type": "Checkpoint Loader w/Name (WLSH)", + "pos": [ + 27, + 69 + ], + "size": [ + 350, + 118 + ], + "flags": {}, + "order": 4, + "mode": 0, + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 38 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 40 + ], + "shape": 3, + "slot_index": 1 + }, + { + "name": "VAE", + "type": "VAE", + "links": null, + "shape": 3 + }, + { + "name": "modelname", + "type": "STRING", + "links": [ + 46 + ], + "shape": 3, + "slot_index": 3 + } + ], + "properties": { + "Node name for S&R": "Checkpoint Loader w/Name (WLSH)" + }, + "widgets_values": [ + "1.5/deliberate_v2.safetensors" + ] + }, + { + "id": 27, + "type": "VAELoader", + "pos": [ + 33, + 244 + ], + "size": [ + 335, + 59 + ], + "flags": {}, + "order": 5, + "mode": 0, + "outputs": [ + { + "name": "VAE", + "type": "VAE", + "links": [ + 39 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "VAELoader" + }, + "widgets_values": [ + "vae-ft-mse-840000-ema-pruned.safetensors" + ] + }, + { + "id": 33, + "type": "UpscaleModelLoader", + "pos": [ + 48, + 365 + ], + "size": { + "0": 315, + "1": 58 + }, + "flags": {}, + "order": 6, + "mode": 0, + "outputs": [ + { + "name": "UPSCALE_MODEL", + "type": "UPSCALE_MODEL", + "links": [ + 47 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "UpscaleModelLoader" + }, + "widgets_values": [ + "4x-UltraSharp.pth" + ] + }, + { + "id": 38, + "type": "Resolutions by Ratio (WLSH)", + "pos": [ + 129, + 482 + ], + "size": [ + 226.8000030517578, + 126 + ], + "flags": {}, + "order": 7, + "mode": 0, + "outputs": [ + { + "name": "width", + "type": "INT", + "links": [ + 55 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "height", + "type": "INT", + "links": [ + 56 + ], + "shape": 3, + "slot_index": 1 + } + ], + "properties": { + "Node name for S&R": "Resolutions by Ratio (WLSH)" + }, + "widgets_values": [ + "1:1", + "landscape", + 512 + ] + }, + { + "id": 36, + "type": "PrimitiveNode", + "pos": [ + 464, + 228 + ], + "size": [ + 649.8297424316406, + 138.63140869140625 + ], + "flags": {}, + "order": 8, + "mode": 0, + "outputs": [ + { + "name": "STRING", + "type": "STRING", + "links": [ + 52, + 65 + ], + "slot_index": 0, + "widget": { + "name": "text", + "config": [ + "STRING", + { + "multiline": true + } + ] + }, + "label": "negative" + } + ], + "title": "Negative (Primitive)", + "properties": {}, + "widgets_values": [ + "photo" + ] + }, + { + "id": 19, + "type": "RebatchLatents", + "pos": [ + 636, + 546 + ], + "size": { + "0": 210, + "1": 58 + }, + "flags": {}, + "order": 15, + "mode": 0, + "inputs": [ + { + "name": "latents", + "type": "LATENT", + "link": 57 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 59 + ], + "shape": 6, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "RebatchLatents" + }, + "widgets_values": [ + 1 + ] + }, + { + "id": 37, + "type": "EmptyLatentImage", + "pos": [ + 410, + 543 + ], + "size": [ + 210, + 90 + ], + "flags": {}, + "order": 12, + "mode": 0, + "inputs": [ + { + "name": "width", + "type": "INT", + "link": 55, + "widget": { + "name": "width", + "config": [ + "INT", + { + "default": 512, + "min": 64, + "max": 8192, + "step": 8 + } + ] + } + }, + { + "name": "height", + "type": "INT", + "link": 56, + "widget": { + "name": "height", + "config": [ + "INT", + { + "default": 512, + "min": 64, + "max": 8192, + "step": 8 + } + ] + } + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 57 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage" + }, + "widgets_values": [ + 512, + 512, + 1 + ] + } + ], + "links": [ + [ + 19, + 15, + 0, + 8, + 1, + "VAE" + ], + [ + 38, + 26, + 0, + 13, + 0, + "*" + ], + [ + 39, + 27, + 0, + 15, + 0, + "*" + ], + [ + 40, + 26, + 1, + 14, + 0, + "*" + ], + [ + 42, + 13, + 0, + 29, + 0, + "MODEL" + ], + [ + 43, + 14, + 0, + 30, + 0, + "CLIP" + ], + [ + 45, + 31, + 0, + 28, + 6, + "STRING" + ], + [ + 46, + 26, + 3, + 28, + 5, + "STRING" + ], + [ + 47, + 33, + 0, + 32, + 0, + "UPSCALE_MODEL" + ], + [ + 48, + 8, + 0, + 32, + 1, + "IMAGE" + ], + [ + 49, + 29, + 0, + 8, + 0, + "LATENT" + ], + [ + 50, + 29, + 1, + 28, + 1, + "INFO" + ], + [ + 51, + 34, + 0, + 30, + 1, + "STRING" + ], + [ + 52, + 36, + 0, + 35, + 1, + "STRING" + ], + [ + 53, + 14, + 0, + 35, + 0, + "CLIP" + ], + [ + 54, + 32, + 0, + 28, + 0, + "IMAGE" + ], + [ + 55, + 38, + 0, + 37, + 0, + "INT" + ], + [ + 56, + 38, + 1, + 37, + 1, + "INT" + ], + [ + 57, + 37, + 0, + 19, + 0, + "LATENT" + ], + [ + 58, + 39, + 0, + 29, + 4, + "INT" + ], + [ + 59, + 19, + 0, + 29, + 3, + "LATENT" + ], + [ + 60, + 30, + 0, + 29, + 1, + "CONDITIONING" + ], + [ + 61, + 35, + 0, + 29, + 2, + "CONDITIONING" + ], + [ + 62, + 32, + 0, + 10, + 0, + "IMAGE" + ], + [ + 64, + 34, + 0, + 28, + 2, + "STRING" + ], + [ + 65, + 36, + 0, + 28, + 3, + "STRING" + ], + [ + 67, + 40, + 0, + 28, + 7, + "INT" + ], + [ + 68, + 39, + 0, + 28, + 4, + "INT" + ] + ], + "groups": [], + "config": {}, + "extra": {}, + "version": 0.4 +} \ No newline at end of file diff --git a/wlsh_nodes.py b/wlsh_nodes.py index ef3ff77..f055dd8 100644 --- a/wlsh_nodes.py +++ b/wlsh_nodes.py @@ -43,6 +43,7 @@ class WLSH_Checkpoint_Loader_Model_Name: return {"required": { "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ), }} RETURN_TYPES = ("MODEL", "CLIP", "VAE","STRING",) + RETURN_NAMES = ("MODEL", "CLIP", "VAE", "modelname") FUNCTION = "load_checkpoint" CATEGORY = "WLSH Nodes/loaders" @@ -774,6 +775,7 @@ def make_comment(positive, negative, modelname="unknown", seed=-1, info=None): class WLSH_Image_Save_With_Prompt_Info: def __init__(self): # get default output directory + self.type = "output" self.output_dir = folder_paths.output_directory @classmethod @@ -821,11 +823,11 @@ class WLSH_Image_Save_With_Prompt_Info: print(f'The path `{output_path.strip()}` specified doesn\'t exist! Creating directory.') os.makedirs(output_path, exist_ok=True) - paths = self.save_images(images, output_path,filename,comment, extension, quality, prompt, extra_pnginfo) + paths = self.save_images(images, output_path,path, filename,comment, extension, quality, prompt, extra_pnginfo) return { "ui": { "images": paths } } - def save_images(self, images, output_path, filename_prefix="ComfyUI", comment="", extension='png', quality=100, prompt=None, extra_pnginfo=None): + def save_images(self, images, output_path, path, filename_prefix="ComfyUI", comment="", extension='png', quality=100, prompt=None, extra_pnginfo=None): def map_filename(filename): prefix_len = len(filename_prefix) prefix = filename[:prefix_len + 1] @@ -864,14 +866,20 @@ class WLSH_Image_Save_With_Prompt_Info: img.save(os.path.join(output_path, file), quality=quality, optimize=True) else: img.save(os.path.join(output_path, file)) - paths.append(file) + paths.append({ + "filename": file, + "subfolder": path, + "type": self.type + }) imgCount += 1 return(paths) + class WLSH_Image_Save_With_Prompt_File: def __init__(self): # get default output directory self.output_dir = folder_paths.output_directory + self.type = "output" @classmethod def INPUT_TYPES(s): @@ -917,11 +925,11 @@ class WLSH_Image_Save_With_Prompt_File: os.makedirs(output_path, exist_ok=True) paths = self.save_images(images, output_path,filename,comment, extension, quality, prompt, extra_pnginfo) - self.save_text_file(filename, output_path, comment, seed, modelname) + self.save_text_file(filename,path, output_path, comment, seed, modelname) #return return { "ui": { "images": paths } } - def save_images(self, images, output_path, filename_prefix="ComfyUI", comment="", extension='png', quality=100, prompt=None, extra_pnginfo=None): + def save_images(self, images, output_path, path, filename_prefix="ComfyUI", comment="", extension='png', quality=100, prompt=None, extra_pnginfo=None): def map_filename(filename): prefix_len = len(filename_prefix) prefix = filename[:prefix_len + 1] @@ -959,7 +967,11 @@ class WLSH_Image_Save_With_Prompt_File: img.save(os.path.join(output_path, file), quality=quality, optimize=True) else: img.save(os.path.join(output_path, file)) - paths.append(file) + paths.append({ + "filename": file, + "subfolder": path, + "type": self.type + }) imgCount += 1 return(paths)