From b68cb29fab9ca989a160886068e940f76bd2b326 Mon Sep 17 00:00:00 2001 From: Bruno Fargnoli Date: Thu, 28 May 2026 13:38:02 +0200 Subject: [PATCH] Added Initial Setup --- ...dit Mesh Projection with TexturedView.json | 183 ++---- .../Qwen Edit Mesh Projection.json | 2 +- ... Edit Inpainting with ImageRef - NoBg.json | 447 ++++++++++++++ ...n Image Edit Inpainting with ImageRef.json | 164 +++-- .../Qwen Image Edit Projected View.json | 301 +++++++++ server.js | 496 ++++++++++++++- setup/Gen Image with Flux2Dev.json | 205 ++++++ setup/Gen Image with QwenImage2512.json | 141 +++++ setup/Gen Image with ZImageTurbo.json | 126 ++++ setup/Gen Mesh Only with Trellis2.json | 289 +++++++++ ...ction TexturedView with QwenImageEdit.json | 429 +++++++++++++ setup/Mesh Projection with QwenImageEdit.json | 402 ++++++++++++ setup/setup.json | 145 +++++ src/components/SetupWizardModal.css | 286 +++++++++ src/components/SetupWizardModal.jsx | 582 ++++++++++++++++++ src/context/SettingsContext.jsx | 1 + src/pages/MeshEditorPage.jsx | 2 +- src/pages/ProjectsPage.css | 28 + src/pages/ProjectsPage.jsx | 43 +- storage.js | 1 + 20 files changed, 4066 insertions(+), 207 deletions(-) create mode 100644 comfyui_workflows/Qwen Image Edit Inpainting with ImageRef - NoBg.json create mode 100644 comfyui_workflows/Qwen Image Edit Projected View.json create mode 100644 setup/Gen Image with Flux2Dev.json create mode 100644 setup/Gen Image with QwenImage2512.json create mode 100644 setup/Gen Image with ZImageTurbo.json create mode 100644 setup/Gen Mesh Only with Trellis2.json create mode 100644 setup/Mesh Projection TexturedView with QwenImageEdit.json create mode 100644 setup/Mesh Projection with QwenImageEdit.json create mode 100644 setup/setup.json create mode 100644 src/components/SetupWizardModal.css create mode 100644 src/components/SetupWizardModal.jsx diff --git a/comfyui_workflows/Qwen Edit Mesh Projection with TexturedView.json b/comfyui_workflows/Qwen Edit Mesh Projection with TexturedView.json index 71969d7..e27ffbd 100644 --- a/comfyui_workflows/Qwen Edit Mesh Projection with TexturedView.json +++ b/comfyui_workflows/Qwen Edit Mesh Projection with TexturedView.json @@ -35,7 +35,7 @@ "3": { "inputs": { "conditioning": [ - "58", + "9", 0 ], "latent": [ @@ -51,7 +51,7 @@ "4": { "inputs": { "pixels": [ - "33", + "38", 0 ], "vae": [ @@ -67,6 +67,7 @@ "5": { "inputs": { "strength": 1, + "pre_cfg": false, "model": [ "1", 0 @@ -97,7 +98,7 @@ "7": { "inputs": { "conditioning": [ - "57", + "8", 0 ], "latent": [ @@ -112,7 +113,7 @@ }, "8": { "inputs": { - "prompt": "Draw the front-right side view", + "prompt": "Draw the front-left side view", "clip": [ "14", 0 @@ -237,7 +238,7 @@ }, "20": { "inputs": { - "seed": 1000, + "seed": 433735871179849, "steps": 4, "cfg": 1, "sampler_name": "euler", @@ -341,20 +342,6 @@ "title": "ImageCompositeMasked" } }, - "33": { - "inputs": { - "low_threshold": 0.05, - "high_threshold": 0.25, - "image": [ - "21", - 0 - ] - }, - "class_type": "Canny", - "_meta": { - "title": "Canny" - } - }, "34": { "inputs": { "value": 1024 @@ -364,128 +351,26 @@ "title": "Image Resolution" } }, - "56": { + "35": { "inputs": { - "pixels": [ - "63", - 0 - ], - "vae": [ - "15", + "filename_prefix": "Qwen", + "images": [ + "36", 0 ] }, - "class_type": "VAEEncode", + "class_type": "SaveImage", "_meta": { - "title": "VAE Encode" + "title": "Save Image" } }, - "57": { - "inputs": { - "conditioning": [ - "8", - 0 - ], - "latent": [ - "56", - 0 - ] - }, - "class_type": "ReferenceLatent", - "_meta": { - "title": "ReferenceLatent" - } - }, - "58": { - "inputs": { - "conditioning": [ - "9", - 0 - ], - "latent": [ - "56", - 0 - ] - }, - "class_type": "ReferenceLatent", - "_meta": { - "title": "ReferenceLatent" - } - }, - "59": { - "inputs": { - "image": "projection-textured-view.png" - }, - "class_type": "LoadImage", - "_meta": { - "title": "Textured View" - } - }, - "60": { - "inputs": { - "value": 1, - "width": 1024, - "height": 1024 - }, - "class_type": "SolidMask", - "_meta": { - "title": "SolidMask" - } - }, - "61": { - "inputs": { - "mask": [ - "59", - 1 - ] - }, - "class_type": "InvertMask", - "_meta": { - "title": "InvertMask" - } - }, - "62": { - "inputs": { - "mask": [ - "60", - 0 - ] - }, - "class_type": "MaskToImage", - "_meta": { - "title": "Convert Mask to Image" - } - }, - "63": { - "inputs": { - "x": 0, - "y": 0, - "resize_source": false, - "destination": [ - "62", - 0 - ], - "source": [ - "59", - 0 - ], - "mask": [ - "61", - 0 - ] - }, - "class_type": "ImageCompositeMasked", - "_meta": { - "title": "ImageCompositeMasked" - } - }, - "73": { + "36": { "inputs": { "model": "RMBG-2.0", "sensitivity": 1, "process_res": 1024, "mask_blur": 0, - "mask_offset": 0, + "mask_offset": -1, "invert_output": false, "refine_foreground": false, "background": "Alpha", @@ -500,17 +385,45 @@ "title": "Remove Background (RMBG)" } }, - "74": { + "37": { "inputs": { - "filename_prefix": "Qwen", - "images": [ - "73", + "image": "projection-textured-view.png" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Textured View" + } + }, + "38": { + "inputs": { + "blend_factor": 1, + "blend_mode": "screen", + "image1": [ + "37", + 0 + ], + "image2": [ + "39", 0 ] }, - "class_type": "SaveImage", + "class_type": "ImageBlend", "_meta": { - "title": "Save Image" + "title": "Blend Images" + } + }, + "39": { + "inputs": { + "low_threshold": 0.05, + "high_threshold": 0.25, + "image": [ + "21", + 0 + ] + }, + "class_type": "Canny", + "_meta": { + "title": "Canny" } } } \ No newline at end of file diff --git a/comfyui_workflows/Qwen Edit Mesh Projection.json b/comfyui_workflows/Qwen Edit Mesh Projection.json index 6e8174e..a3a0a54 100644 --- a/comfyui_workflows/Qwen Edit Mesh Projection.json +++ b/comfyui_workflows/Qwen Edit Mesh Projection.json @@ -383,7 +383,7 @@ "sensitivity": 1, "process_res": 1024, "mask_blur": 0, - "mask_offset": 0, + "mask_offset": -1, "invert_output": false, "refine_foreground": false, "background": "Alpha", diff --git a/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef - NoBg.json b/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef - NoBg.json new file mode 100644 index 0000000..9843716 --- /dev/null +++ b/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef - NoBg.json @@ -0,0 +1,447 @@ +{ + "1": { + "inputs": { + "prompt": "Redraw the tower", + "clip": [ + "33", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus (Positive Prompt)" + } + }, + "10": { + "inputs": { + "vae_name": "qwen_image_vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "11": { + "inputs": { + "image": "clipspace/clipspace-painted-masked-1779897577438.png [input]" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Image Source" + } + }, + "13": { + "inputs": { + "samples": [ + "152", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "14": { + "inputs": { + "filename_prefix": "ComfyUI", + "images": [ + "170", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "24": { + "inputs": { + "lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", + "strength_model": 1, + "model": [ + "160", + 0 + ] + }, + "class_type": "LoraLoaderModelOnly", + "_meta": { + "title": "Load LoRA" + } + }, + "30": { + "inputs": { + "shift": 3.1, + "model": [ + "24", + 0 + ] + }, + "class_type": "ModelSamplingAuraFlow", + "_meta": { + "title": "ModelSamplingAuraFlow" + } + }, + "33": { + "inputs": { + "clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors", + "type": "qwen_image", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "39": { + "inputs": { + "prompt": "", + "clip": [ + "33", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus (Negative Prompt)" + } + }, + "119": { + "inputs": { + "pixels": [ + "158", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "126": { + "inputs": { + "samples": [ + "119", + 0 + ], + "mask": [ + "148", + 0 + ] + }, + "class_type": "SetLatentNoiseMask", + "_meta": { + "title": "Set Latent Noise Mask" + } + }, + "128": { + "inputs": { + "expand": 0, + "incremental_expandrate": 0, + "tapered_corners": true, + "flip_input": false, + "blur_radius": 20, + "lerp_alpha": 1, + "decay_factor": 1, + "fill_holes": false, + "mask": [ + "169", + 0 + ] + }, + "class_type": "GrowMaskWithBlur", + "_meta": { + "title": "Grow Mask With Blur" + } + }, + "129": { + "inputs": { + "pixels": [ + "138", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "130": { + "inputs": { + "samples": [ + "129", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "132": { + "inputs": { + "image": [ + "130", + 0 + ] + }, + "class_type": "GetImageSize", + "_meta": { + "title": "Get Image Size" + } + }, + "138": { + "inputs": { + "upscale_method": "lanczos", + "largest_size": [ + "163", + 0 + ], + "image": [ + "11", + 0 + ] + }, + "class_type": "ImageScaleToMaxDimension", + "_meta": { + "title": "ImageScaleToMaxDimension" + } + }, + "148": { + "inputs": { + "width": [ + "132", + 0 + ], + "height": [ + "132", + 1 + ], + "keep_proportions": true, + "upscale_method": "lanczos", + "crop": "center", + "mask": [ + "128", + 0 + ] + }, + "class_type": "ResizeMask", + "_meta": { + "title": "Resize Mask" + } + }, + "152": { + "inputs": { + "seed": 359473559919449, + "steps": 4, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1, + "model": [ + "30", + 0 + ], + "positive": [ + "165", + 0 + ], + "negative": [ + "168", + 0 + ], + "latent_image": [ + "126", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "158": { + "inputs": { + "upscale_method": "lanczos", + "width": [ + "132", + 0 + ], + "height": [ + "132", + 1 + ], + "crop": "center", + "image": [ + "11", + 0 + ] + }, + "class_type": "ImageScale", + "_meta": { + "title": "Upscale Image" + } + }, + "160": { + "inputs": { + "unet_name": "qwen-image-edit-2511-Q6_K.gguf" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "162": { + "inputs": { + "image": "Image_1024_00192_.png" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Image Reference" + } + }, + "163": { + "inputs": { + "value": 1024 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Image Resolution" + } + }, + "164": { + "inputs": { + "conditioning": [ + "1", + 0 + ], + "latent": [ + "129", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "165": { + "inputs": { + "conditioning": [ + "164", + 0 + ], + "latent": [ + "166", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "166": { + "inputs": { + "pixels": [ + "162", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "167": { + "inputs": { + "conditioning": [ + "39", + 0 + ], + "latent": [ + "129", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "168": { + "inputs": { + "conditioning": [ + "167", + 0 + ], + "latent": [ + "166", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "169": { + "inputs": { + "image": "Textured - 2048-mask.png", + "channel": "red" + }, + "class_type": "LoadImageMask", + "_meta": { + "title": "Load Image (as Mask)" + } + }, + "170": { + "inputs": { + "model": "RMBG-2.0", + "sensitivity": 1, + "process_res": 1024, + "mask_blur": 0, + "mask_offset": 0, + "invert_output": false, + "refine_foreground": false, + "background": "Alpha", + "background_color": "#222222", + "image": [ + "13", + 0 + ] + }, + "class_type": "RMBG", + "_meta": { + "title": "Remove Background (RMBG)" + } + } +} \ No newline at end of file diff --git a/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef.json b/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef.json index c48e5e4..581105c 100644 --- a/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef.json +++ b/comfyui_workflows/Qwen Image Edit Inpainting with ImageRef.json @@ -1,7 +1,7 @@ { "1": { "inputs": { - "prompt": "Make a gold face", + "prompt": "Redraw the tower", "clip": [ "33", 0 @@ -9,14 +9,6 @@ "vae": [ "10", 0 - ], - "image1": [ - "158", - 0 - ], - "image2": [ - "162", - 0 ] }, "class_type": "TextEncodeQwenImageEditPlus", @@ -35,7 +27,7 @@ }, "11": { "inputs": { - "image": "clipspace/clipspace-painted-masked-1777042923407.png [input]" + "image": "clipspace/clipspace-painted-masked-1779897577438.png [input]" }, "class_type": "LoadImage", "_meta": { @@ -119,14 +111,6 @@ "vae": [ "10", 0 - ], - "image1": [ - "158", - 0 - ], - "image2": [ - "162", - 0 ] }, "class_type": "TextEncodeQwenImageEditPlus", @@ -134,36 +118,6 @@ "title": "TextEncodeQwenImageEditPlus (Negative Prompt)" } }, - "51": { - "inputs": { - "rgthree_comparer": { - "images": [ - { - "name": "A", - "selected": true, - "url": "/api/view?filename=rgthree.compare._temp_hulpi_00003_.png&type=temp&subfolder=&rand=0.4879672000794206" - }, - { - "name": "B", - "selected": true, - "url": "/api/view?filename=rgthree.compare._temp_hulpi_00004_.png&type=temp&subfolder=&rand=0.17245221973947011" - } - ] - }, - "image_a": [ - "11", - 0 - ], - "image_b": [ - "13", - 0 - ] - }, - "class_type": "Image Comparer (rgthree)", - "_meta": { - "title": "Image Comparer (rgthree)" - } - }, "119": { "inputs": { "pixels": [ @@ -202,12 +156,12 @@ "incremental_expandrate": 0, "tapered_corners": true, "flip_input": false, - "blur_radius": 31.3, + "blur_radius": 20, "lerp_alpha": 1, "decay_factor": 1, "fill_holes": false, "mask": [ - "161", + "169", 0 ] }, @@ -302,7 +256,7 @@ }, "152": { "inputs": { - "seed": 258107651719923, + "seed": 359473559919449, "steps": 4, "cfg": 1, "sampler_name": "euler", @@ -313,11 +267,11 @@ 0 ], "positive": [ - "1", + "165", 0 ], "negative": [ - "39", + "168", 0 ], "latent_image": [ @@ -354,26 +308,16 @@ }, "160": { "inputs": { - "unet_name": "qwen-image-edit-2511-Q4_K_M.gguf" + "unet_name": "qwen-image-edit-2511-Q6_K.gguf" }, "class_type": "UnetLoaderGGUF", "_meta": { "title": "Unet Loader (GGUF)" } }, - "161": { - "inputs": { - "image": "Textured - 2048-mask.png", - "channel": "red" - }, - "class_type": "LoadImageMask", - "_meta": { - "title": "Load Image (as Mask)" - } - }, "162": { "inputs": { - "image": "1777215503646-366819398.png" + "image": "Image_1024_00192_.png" }, "class_type": "LoadImage", "_meta": { @@ -388,5 +332,95 @@ "_meta": { "title": "Image Resolution" } + }, + "164": { + "inputs": { + "conditioning": [ + "1", + 0 + ], + "latent": [ + "129", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "165": { + "inputs": { + "conditioning": [ + "164", + 0 + ], + "latent": [ + "166", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "166": { + "inputs": { + "pixels": [ + "162", + 0 + ], + "vae": [ + "10", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "167": { + "inputs": { + "conditioning": [ + "39", + 0 + ], + "latent": [ + "129", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "168": { + "inputs": { + "conditioning": [ + "167", + 0 + ], + "latent": [ + "166", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "169": { + "inputs": { + "image": "Textured - 2048-mask.png", + "channel": "red" + }, + "class_type": "LoadImageMask", + "_meta": { + "title": "Load Image (as Mask)" + } } } \ No newline at end of file diff --git a/comfyui_workflows/Qwen Image Edit Projected View.json b/comfyui_workflows/Qwen Image Edit Projected View.json new file mode 100644 index 0000000..f0e2365 --- /dev/null +++ b/comfyui_workflows/Qwen Image Edit Projected View.json @@ -0,0 +1,301 @@ +{ + "1": { + "inputs": { + "shift": 3.1, + "model": [ + "15", + 0 + ] + }, + "class_type": "ModelSamplingAuraFlow", + "_meta": { + "title": "ModelSamplingAuraFlow" + } + }, + "2": { + "inputs": { + "tile_size": 128, + "overlap": 64, + "temporal_size": 64, + "temporal_overlap": 8, + "samples": [ + "20", + 0 + ], + "vae": [ + "17", + 0 + ] + }, + "class_type": "VAEDecodeTiled", + "_meta": { + "title": "VAE Decode (Tiled)" + } + }, + "3": { + "inputs": { + "conditioning": [ + "9", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "4": { + "inputs": { + "pixels": [ + "22", + 0 + ], + "vae": [ + "17", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "5": { + "inputs": { + "strength": 1, + "model": [ + "1", + 0 + ] + }, + "class_type": "CFGNorm", + "_meta": { + "title": "CFGNorm" + } + }, + "6": { + "inputs": { + "width": 1024, + "height": 1024, + "batch_size": 1 + }, + "class_type": "EmptyLatentImage", + "_meta": { + "title": "Empty Latent Image" + } + }, + "7": { + "inputs": { + "conditioning": [ + "8", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "8": { + "inputs": { + "prompt": "Generate the front view", + "clip": [ + "16", + 0 + ], + "vae": [ + "17", + 0 + ], + "image1": [ + "23", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus (Positive)" + } + }, + "9": { + "inputs": { + "prompt": "", + "clip": [ + "16", + 0 + ], + "vae": [ + "17", + 0 + ], + "image1": [ + "23", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus" + } + }, + "10": { + "inputs": { + "conditioning": [ + "7", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "11": { + "inputs": { + "conditioning": [ + "3", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "12": { + "inputs": { + "pixels": [ + "23", + 0 + ], + "vae": [ + "17", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "15": { + "inputs": { + "lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", + "strength_model": 1, + "model": [ + "19", + 0 + ] + }, + "class_type": "LoraLoaderModelOnly", + "_meta": { + "title": "Load LoRA" + } + }, + "16": { + "inputs": { + "clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors", + "type": "qwen_image", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "17": { + "inputs": { + "vae_name": "qwen_image_vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "19": { + "inputs": { + "unet_name": "qwen-image-edit-2511-Q6_K.gguf" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "20": { + "inputs": { + "seed": 1000, + "steps": 4, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1, + "model": [ + "5", + 0 + ], + "positive": [ + "10", + 0 + ], + "negative": [ + "11", + 0 + ], + "latent_image": [ + "6", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "21": { + "inputs": { + "filename_prefix": "Qwen", + "images": [ + "2", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "22": { + "inputs": { + "image": "DwarfSorcerer FireBeard-mask-v0.png" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Canny Image" + } + }, + "23": { + "inputs": { + "image": "DwarfSorcerer FireBeard-mask-v0.png" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Source Image" + } + } +} \ No newline at end of file diff --git a/server.js b/server.js index fb9eeb4..550ff37 100644 --- a/server.js +++ b/server.js @@ -6,6 +6,10 @@ import { Buffer } from 'buffer'; import { randomUUID } from 'crypto'; import { createAssetEditRecord, createBrushChildRecord, resolveProjectImageSource, resolveProjectMeshSource } from './storage.js'; import fs from 'fs/promises'; +import { createWriteStream } from 'node:fs'; +import { spawn } from 'node:child_process'; +import process from 'node:process'; +import { fileURLToPath } from 'node:url'; import si from 'systeminformation'; import tencentcloudSdk from 'tencentcloud-sdk-nodejs-intl-en'; import { @@ -5438,7 +5442,7 @@ app.get('/api/system/stats', async (req, res) => { // This works regardless of whether it's NVIDIA, AMD, or Intel Arc. const gpu = graphics.controllers.reduce((prev, current) => { return (current.vram > (prev.vram || 0)) ? current : prev; - }, graphics.controllers[0]); + }, graphics.controllers[0] || {}); // 2. Universal Mapping: Check for both 'memoryUsed' (NVIDIA style) // and 'vramUsage' (AMD/Standard style) @@ -5466,6 +5470,496 @@ app.get('/api/system/stats', async (req, res) => { } }); +// ─── INITIAL SETUP ─── + +const SETUP_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), 'setup'); +const SETUP_CONFIG_PATH = path.join(SETUP_DIR, 'setup.json'); +const SETUP_TYPE_TO_VALUE_TYPE = { Image: 'image', String: 'string', Number: 'number', Boolean: 'boolean' }; +const setupDownloadJobs = new Map(); + +function getSetupDownloadJob(jobId) { + if (!setupDownloadJobs.has(jobId)) { + setupDownloadJobs.set(jobId, { subscribers: new Set(), snapshot: null }); + } + return setupDownloadJobs.get(jobId); +} + +function publishSetupDownloadProgress(jobId, payload) { + const job = getSetupDownloadJob(jobId); + const message = { jobId, timestamp: Date.now(), ...payload }; + job.snapshot = message; + + for (const response of job.subscribers) { + response.write(`data: ${JSON.stringify(message)}\n\n`); + } + + if (message.status === 'done' || message.status === 'error') { + setTimeout(() => { + if (job.subscribers.size === 0) { + setupDownloadJobs.delete(jobId); + } + }, 60000); + } +} + +function subscribeSetupDownload(jobId, req, res) { + const job = getSetupDownloadJob(jobId); + + res.setHeader('Content-Type', 'text/event-stream'); + res.setHeader('Cache-Control', 'no-cache, no-transform'); + res.setHeader('Connection', 'keep-alive'); + res.setHeader('X-Accel-Buffering', 'no'); + res.flushHeaders?.(); + res.write('retry: 1000\n\n'); + + job.subscribers.add(res); + + if (job.snapshot) { + res.write(`data: ${JSON.stringify(job.snapshot)}\n\n`); + } + + const heartbeat = setInterval(() => res.write(': keep-alive\n\n'), 15000); + + req.on('close', () => { + clearInterval(heartbeat); + job.subscribers.delete(res); + }); +} + +async function loadSetupConfig() { + const raw = await fs.readFile(SETUP_CONFIG_PATH, 'utf-8'); + return JSON.parse(raw); +} + +async function pathExists(targetPath) { + try { + await fs.access(targetPath); + return true; + } catch { + return false; + } +} + +async function fileSizeOrNull(targetPath) { + try { + const stat = await fs.stat(targetPath); + return stat.isFile() ? stat.size : null; + } catch { + return null; + } +} + +function resolveComfySubPath(comfyPath, relativePath) { + const normalizedRelative = String(relativePath || '').replace(/^[/\\]+/, ''); + return path.join(comfyPath, normalizedRelative); +} + +async function downloadFileWithProgress(url, destinationPath, onChunk) { + const response = await fetch(url); + if (!response.ok || !response.body) { + throw new Error(`Download failed (${response.status} ${response.statusText})`); + } + + const totalBytes = Number(response.headers.get('content-length')) || 0; + const tempPath = `${destinationPath}.part`; + const writeStream = createWriteStream(tempPath); + + let receivedBytes = 0; + + try { + for await (const chunk of response.body) { + const writeOk = writeStream.write(chunk); + if (!writeOk) { + await new Promise(resolve => writeStream.once('drain', resolve)); + } + receivedBytes += chunk.length; + onChunk?.(receivedBytes, totalBytes); + } + + await new Promise((resolve, reject) => { + writeStream.end(err => err ? reject(err) : resolve()); + }); + + await fs.rename(tempPath, destinationPath); + } catch (err) { + writeStream.destroy(); + try { await fs.unlink(tempPath); } catch { /* best-effort cleanup */ } + throw err; + } + + return { receivedBytes, totalBytes }; +} + +async function runSetupDownloads(jobId, comfyPath, files) { + const totalExpectedBytes = files.reduce((sum, file) => sum + (Number(file.expectedBytes) || 0), 0); + let cumulativeCompletedBytes = 0; + + publishSetupDownloadProgress(jobId, { + status: 'downloading', + currentIndex: 0, + totalFiles: files.length, + currentFile: files[0]?.fileName || '', + currentBytes: 0, + currentTotalBytes: 0, + currentPercent: 0, + overallPercent: 0 + }); + + for (let index = 0; index < files.length; index += 1) { + const file = files[index]; + const destinationPath = resolveComfySubPath(comfyPath, path.join(file.relativeDir, file.fileName)); + + try { + await fs.mkdir(path.dirname(destinationPath), { recursive: true }); + + const existingSize = await fileSizeOrNull(destinationPath); + if (existingSize !== null && existingSize > 0) { + cumulativeCompletedBytes += existingSize; + publishSetupDownloadProgress(jobId, { + status: 'downloading', + currentIndex: index, + totalFiles: files.length, + currentFile: file.fileName, + currentBytes: existingSize, + currentTotalBytes: existingSize, + currentPercent: 100, + overallPercent: totalExpectedBytes > 0 ? Math.min(100, Math.round((cumulativeCompletedBytes / totalExpectedBytes) * 100)) : 0, + skipped: true + }); + continue; + } + + let lastEmit = 0; + let lastReceived = 0; + + const result = await downloadFileWithProgress(file.url, destinationPath, (currentBytes, currentTotalBytes) => { + const now = Date.now(); + if (now - lastEmit < 200 && currentBytes < currentTotalBytes) { + return; + } + lastEmit = now; + lastReceived = currentBytes; + + publishSetupDownloadProgress(jobId, { + status: 'downloading', + currentIndex: index, + totalFiles: files.length, + currentFile: file.fileName, + currentBytes, + currentTotalBytes, + currentPercent: currentTotalBytes > 0 ? Math.round((currentBytes / currentTotalBytes) * 100) : 0, + overallPercent: totalExpectedBytes > 0 ? Math.min(100, Math.round(((cumulativeCompletedBytes + currentBytes) / totalExpectedBytes) * 100)) : 0 + }); + }); + + cumulativeCompletedBytes += Math.max(result.receivedBytes, lastReceived); + + publishSetupDownloadProgress(jobId, { + status: 'downloading', + currentIndex: index, + totalFiles: files.length, + currentFile: file.fileName, + currentBytes: result.receivedBytes, + currentTotalBytes: result.totalBytes || result.receivedBytes, + currentPercent: 100, + overallPercent: totalExpectedBytes > 0 ? Math.min(100, Math.round((cumulativeCompletedBytes / totalExpectedBytes) * 100)) : 0 + }); + } catch (err) { + console.error(`[setup] download failed for ${file.fileName}:`, err); + publishSetupDownloadProgress(jobId, { + status: 'error', + currentIndex: index, + totalFiles: files.length, + currentFile: file.fileName, + error: err.message || String(err) + }); + return; + } + } + + publishSetupDownloadProgress(jobId, { + status: 'done', + totalFiles: files.length, + currentIndex: files.length, + overallPercent: 100 + }); +} + +async function installSetupWorkflow(workflowConfig, diffusionModelFileName) { + if (!workflowConfig?.File) { + throw new Error('Workflow configuration is missing a File path'); + } + + const absoluteWorkflowPath = path.join(path.dirname(fileURLToPath(import.meta.url)), workflowConfig.File); + const rawJson = await fs.readFile(absoluteWorkflowPath, 'utf-8'); + const substitutedJson = rawJson.replaceAll('{diffusion_model}', diffusionModelFileName); + const workflowJson = JSON.parse(substitutedJson); + + const parsedWorkflow = parseComfyWorkflow(workflowJson); + const availableParameters = new Map(parsedWorkflow.inputs.map(input => [input.id, input])); + const availableOutputs = new Map(parsedWorkflow.outputs.map(output => [String(output.nodeId), output])); + + const parameters = []; + for (const inputCfg of workflowConfig.Inputs || []) { + const parameterId = `${inputCfg.Node}.${inputCfg.Input}`; + const sourceParameter = availableParameters.get(parameterId); + if (!sourceParameter) { + throw new Error(`Workflow "${workflowConfig.Name}": input ${parameterId} not found`); + } + parameters.push({ + ...sourceParameter, + name: sanitizeDisplayName(inputCfg.Name || sourceParameter.name, sourceParameter.name), + valueType: normalizeComfyValueType(SETUP_TYPE_TO_VALUE_TYPE[inputCfg.Type], getDefaultComfyValueType(sourceParameter)) + }); + } + + const outputs = []; + for (const outputCfg of workflowConfig.Outputs || []) { + const outputNodeId = String(outputCfg.Node); + const sourceOutput = availableOutputs.get(outputNodeId); + if (!sourceOutput) { + throw new Error(`Workflow "${workflowConfig.Name}": output node ${outputNodeId} not found`); + } + outputs.push({ + ...sourceOutput, + name: sanitizeDisplayName(outputCfg.Name || sourceOutput.nodeTitle, sourceOutput.nodeTitle), + valueType: normalizeComfyValueType(SETUP_TYPE_TO_VALUE_TYPE[outputCfg.Type], 'image') + }); + } + + if (outputs.length === 0) { + throw new Error(`Workflow "${workflowConfig.Name}" has no outputs configured`); + } + + const filePath = await saveWorkflowFile(workflowConfig.Name, workflowJson); + const workflowRecord = await createWorkflowRecord({ + name: sanitizeDisplayName(workflowConfig.Name, 'Workflow'), + filePath, + parameters, + outputs + }); + + return workflowRecord; +} + +async function pickFolderNative({ description = 'Select folder', initialPath = '' } = {}) { + if (process.platform !== 'win32') { + throw new Error('Native folder picker is only available on Windows'); + } + + const safeDescription = String(description).replace(/'/g, "''"); + const safeInitial = String(initialPath || '').replace(/'/g, "''"); + + const script = ` +$ErrorActionPreference = 'Stop' +Add-Type -AssemblyName System.Windows.Forms | Out-Null +$dlg = New-Object System.Windows.Forms.FolderBrowserDialog +$dlg.Description = '${safeDescription}' +$dlg.ShowNewFolderButton = $false +if ('${safeInitial}'.Length -gt 0 -and (Test-Path -LiteralPath '${safeInitial}')) { + $dlg.SelectedPath = '${safeInitial}' +} +$owner = New-Object System.Windows.Forms.Form +$owner.TopMost = $true +$owner.ShowInTaskbar = $false +$owner.WindowState = 'Minimized' +$owner.Opacity = 0 +$owner.Show() +$owner.Activate() +try { + $result = $dlg.ShowDialog($owner) +} finally { + $owner.Close() + $owner.Dispose() +} +if ($result -eq [System.Windows.Forms.DialogResult]::OK) { + Write-Output $dlg.SelectedPath +} +`; + + return await new Promise((resolve, reject) => { + const proc = spawn( + 'powershell.exe', + ['-NoProfile', '-NonInteractive', '-STA', '-Command', script], + { windowsHide: true } + ); + + let stdout = ''; + let stderr = ''; + + proc.stdout.on('data', chunk => { stdout += chunk.toString(); }); + proc.stderr.on('data', chunk => { stderr += chunk.toString(); }); + proc.on('error', err => reject(err)); + proc.on('close', code => { + if (code !== 0) { + reject(new Error(stderr.trim() || `Folder picker exited with code ${code}`)); + return; + } + const selected = stdout.replace(/\r/g, '').split('\n').map(l => l.trim()).filter(Boolean).pop() || ''; + resolve(selected); + }); + }); +} + +app.post('/api/setup/pick-folder', async (req, res) => { + try { + const description = String(req.body?.description || 'Select folder').slice(0, 200); + const initialPath = String(req.body?.initialPath || '').slice(0, 1024); + const selected = await pickFolderNative({ description, initialPath }); + res.json({ path: selected }); + } catch (err) { + console.error('Folder picker failed:', err); + res.status(500).json({ error: err.message || 'Folder picker failed' }); + } +}); + +app.get('/api/setup/config', async (req, res) => { + try { + res.json(await loadSetupConfig()); + } catch (err) { + console.error('Failed to load setup config:', err); + res.status(500).json({ error: err.message || 'Failed to load setup config' }); + } +}); + +app.post('/api/setup/check-comfy-path', async (req, res) => { + try { + const comfyPath = String(req.body?.path || '').trim(); + if (!comfyPath) { + return res.status(400).json({ error: 'A ComfyUI folder path is required' }); + } + + const rootExists = await pathExists(comfyPath); + if (!rootExists) { + return res.status(400).json({ error: `Folder does not exist: ${comfyPath}` }); + } + + const modelsDir = path.join(comfyPath, 'models'); + const modelsExist = await pathExists(modelsDir); + if (!modelsExist) { + return res.status(400).json({ error: `This does not look like a ComfyUI folder (missing "models" subfolder): ${comfyPath}` }); + } + + const config = await loadSetupConfig(); + const created = []; + for (const relativePath of Object.values(config.ComfyUIPaths || {})) { + const target = resolveComfySubPath(comfyPath, relativePath); + if (!(await pathExists(target))) { + await fs.mkdir(target, { recursive: true }); + created.push(relativePath); + } + } + + res.json({ ok: true, comfyPath, createdSubfolders: created }); + } catch (err) { + console.error('Failed to validate ComfyUI path:', err); + res.status(500).json({ error: err.message || 'Failed to validate ComfyUI path' }); + } +}); + +app.post('/api/setup/check-files', async (req, res) => { + try { + const comfyPath = String(req.body?.comfyPath || '').trim(); + const files = Array.isArray(req.body?.files) ? req.body.files : []; + + if (!comfyPath) { + return res.status(400).json({ error: 'comfyPath is required' }); + } + + const results = []; + for (const file of files) { + const absPath = resolveComfySubPath(comfyPath, path.join(file.relativeDir || '', file.fileName || '')); + const size = await fileSizeOrNull(absPath); + results.push({ + relativeDir: file.relativeDir || '', + fileName: file.fileName || '', + exists: size !== null && size > 0, + sizeBytes: size + }); + } + + res.json({ files: results }); + } catch (err) { + console.error('Failed to check setup files:', err); + res.status(500).json({ error: err.message || 'Failed to check setup files' }); + } +}); + +app.post('/api/setup/download', async (req, res) => { + try { + const comfyPath = String(req.body?.comfyPath || '').trim(); + const files = Array.isArray(req.body?.files) ? req.body.files : []; + + if (!comfyPath) { + return res.status(400).json({ error: 'comfyPath is required' }); + } + + if (files.length === 0) { + const jobId = randomUUID(); + publishSetupDownloadProgress(jobId, { status: 'done', totalFiles: 0, currentIndex: 0, overallPercent: 100 }); + return res.json({ jobId }); + } + + const jobId = randomUUID(); + getSetupDownloadJob(jobId); + + runSetupDownloads(jobId, comfyPath, files).catch(err => { + console.error('[setup] download job crashed:', err); + publishSetupDownloadProgress(jobId, { status: 'error', error: err.message || String(err) }); + }); + + res.json({ jobId }); + } catch (err) { + console.error('Failed to start setup downloads:', err); + res.status(500).json({ error: err.message || 'Failed to start setup downloads' }); + } +}); + +app.get('/api/setup/download/progress/:jobId', (req, res) => { + subscribeSetupDownload(req.params.jobId, req, res); +}); + +app.post('/api/setup/install-workflows', async (req, res) => { + try { + const selections = Array.isArray(req.body?.selections) ? req.body.selections : []; + if (selections.length === 0) { + return res.json({ installed: [] }); + } + + const config = await loadSetupConfig(); + const diffusionByName = new Map((config.DiffusionModels || []).map(model => [model.Name, model])); + const installed = []; + const errors = []; + + for (const selection of selections) { + const diffusion = diffusionByName.get(selection.diffusionName); + if (!diffusion) { + errors.push({ diffusionName: selection.diffusionName, error: 'Unknown DiffusionModel' }); + continue; + } + const modelEntry = diffusion.Models?.[selection.modelQuality]; + if (!modelEntry?.FileName) { + errors.push({ diffusionName: selection.diffusionName, error: `Unknown model quality ${selection.modelQuality}` }); + continue; + } + for (const workflowConfig of diffusion.Workflows || []) { + try { + const record = await installSetupWorkflow(workflowConfig, modelEntry.FileName); + installed.push({ id: record.id, name: record.name }); + } catch (err) { + console.error(`[setup] failed to install workflow ${workflowConfig?.Name}:`, err); + errors.push({ workflow: workflowConfig?.Name, error: err.message || String(err) }); + } + } + } + + res.json({ installed, errors }); + } catch (err) { + console.error('Failed to install setup workflows:', err); + res.status(500).json({ error: err.message || 'Failed to install setup workflows' }); + } +}); + // Start server initializeStorage().then(async () => { try { diff --git a/setup/Gen Image with Flux2Dev.json b/setup/Gen Image with Flux2Dev.json new file mode 100644 index 0000000..045a5c5 --- /dev/null +++ b/setup/Gen Image with Flux2Dev.json @@ -0,0 +1,205 @@ +{ + "9": { + "inputs": { + "filename_prefix": "Flux2-Klein", + "images": [ + "97", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "84": { + "inputs": { + "sampler_name": "euler" + }, + "class_type": "KSamplerSelect", + "_meta": { + "title": "KSamplerSelect" + } + }, + "85": { + "inputs": { + "steps": 8, + "width": [ + "90", + 0 + ], + "height": [ + "91", + 0 + ] + }, + "class_type": "Flux2Scheduler", + "_meta": { + "title": "Flux2Scheduler" + } + }, + "86": { + "inputs": { + "cfg": 1.5, + "model": [ + "102", + 0 + ], + "positive": [ + "96", + 0 + ], + "negative": [ + "89", + 0 + ] + }, + "class_type": "CFGGuider", + "_meta": { + "title": "CFGGuider" + } + }, + "87": { + "inputs": { + "noise": [ + "92", + 0 + ], + "guider": [ + "86", + 0 + ], + "sampler": [ + "84", + 0 + ], + "sigmas": [ + "85", + 0 + ], + "latent_image": [ + "88", + 0 + ] + }, + "class_type": "SamplerCustomAdvanced", + "_meta": { + "title": "SamplerCustomAdvanced" + } + }, + "88": { + "inputs": { + "width": [ + "90", + 0 + ], + "height": [ + "91", + 0 + ], + "batch_size": 1 + }, + "class_type": "EmptyFlux2LatentImage", + "_meta": { + "title": "Empty Flux 2 Latent" + } + }, + "89": { + "inputs": { + "text": "blurry, low detail, low contrast, deformed", + "clip": [ + "94", + 0 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Negative Prompt)" + } + }, + "90": { + "inputs": { + "value": 1024 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Width" + } + }, + "91": { + "inputs": { + "value": 1024 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Height" + } + }, + "92": { + "inputs": { + "noise_seed": 12345 + }, + "class_type": "RandomNoise", + "_meta": { + "title": "RandomNoise" + } + }, + "94": { + "inputs": { + "clip_name": "mistral_3_small_flux2_fp4_mixed.safetensors", + "type": "flux2", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "95": { + "inputs": { + "vae_name": "flux2-vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "96": { + "inputs": { + "text": "", + "clip": [ + "94", + 0 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Positive Prompt)" + } + }, + "97": { + "inputs": { + "samples": [ + "87", + 0 + ], + "vae": [ + "95", + 0 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "102": { + "inputs": { + "unet_name": "{diffusion_model}" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + } +} \ No newline at end of file diff --git a/setup/Gen Image with QwenImage2512.json b/setup/Gen Image with QwenImage2512.json new file mode 100644 index 0000000..684b185 --- /dev/null +++ b/setup/Gen Image with QwenImage2512.json @@ -0,0 +1,141 @@ +{ + "90": { + "inputs": { + "filename_prefix": "qwen", + "images": [ + "113", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "110": { + "inputs": { + "vae_name": "qwen_image_vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "112": { + "inputs": { + "text": "", + "clip": [ + "118", + 0 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Positive Prompt)" + } + }, + "113": { + "inputs": { + "samples": [ + "116", + 0 + ], + "vae": [ + "110", + 0 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + }, + "114": { + "inputs": { + "width": 1024, + "height": 1024, + "batch_size": 1 + }, + "class_type": "EmptySD3LatentImage", + "_meta": { + "title": "EmptySD3LatentImage" + } + }, + "115": { + "inputs": { + "text": "低分辨率,低画质,肢体畸形,手指畸形,画面过饱和,蜡像感,人脸无细节,过度光滑,画面具有AI感。构图混乱。文字模糊,扭曲", + "clip": [ + "118", + 0 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Negative Prompt)" + } + }, + "116": { + "inputs": { + "seed": 12346, + "steps": 4, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1, + "model": [ + "119", + 0 + ], + "positive": [ + "112", + 0 + ], + "negative": [ + "115", + 0 + ], + "latent_image": [ + "114", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "117": { + "inputs": { + "unet_name": "{diffusion_model}" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "118": { + "inputs": { + "clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors", + "type": "qwen_image", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "119": { + "inputs": { + "lora_name": "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors", + "strength_model": 1, + "model": [ + "117", + 0 + ] + }, + "class_type": "LoraLoaderModelOnly", + "_meta": { + "title": "Load LoRA" + } + } +} \ No newline at end of file diff --git a/setup/Gen Image with ZImageTurbo.json b/setup/Gen Image with ZImageTurbo.json new file mode 100644 index 0000000..5b87068 --- /dev/null +++ b/setup/Gen Image with ZImageTurbo.json @@ -0,0 +1,126 @@ +{ + "43": { + "inputs": { + "filename_prefix": "z-image", + "images": [ + "34:8", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "44": { + "inputs": { + "unet_name": "{diffusion_model}" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "34:29": { + "inputs": { + "vae_name": "ae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "34:13": { + "inputs": { + "width": 1024, + "height": 1024, + "batch_size": 1 + }, + "class_type": "EmptySD3LatentImage", + "_meta": { + "title": "EmptySD3LatentImage" + } + }, + "34:30": { + "inputs": { + "clip_name": "qwen_3_4b_fp8_mixed.safetensors", + "type": "lumina2", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "34:27": { + "inputs": { + "text": "", + "clip": [ + "34:30", + 0 + ] + }, + "class_type": "CLIPTextEncode", + "_meta": { + "title": "CLIP Text Encode (Prompt)" + } + }, + "34:33": { + "inputs": { + "conditioning": [ + "34:27", + 0 + ] + }, + "class_type": "ConditioningZeroOut", + "_meta": { + "title": "ConditioningZeroOut" + } + }, + "34:3": { + "inputs": { + "seed": 369851808028921, + "steps": 10, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "linear_quadratic", + "denoise": 1, + "model": [ + "44", + 0 + ], + "positive": [ + "34:27", + 0 + ], + "negative": [ + "34:33", + 0 + ], + "latent_image": [ + "34:13", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "34:8": { + "inputs": { + "samples": [ + "34:3", + 0 + ], + "vae": [ + "34:29", + 0 + ] + }, + "class_type": "VAEDecode", + "_meta": { + "title": "VAE Decode" + } + } +} \ No newline at end of file diff --git a/setup/Gen Mesh Only with Trellis2.json b/setup/Gen Mesh Only with Trellis2.json new file mode 100644 index 0000000..aa27eca --- /dev/null +++ b/setup/Gen Mesh Only with Trellis2.json @@ -0,0 +1,289 @@ +{ + "6": { + "inputs": { + "image": "Image_1024_00146_.png" + }, + "class_type": "Trellis2LoadImageWithTransparency", + "_meta": { + "title": "Source Image" + } + }, + "39": { + "inputs": { + "modelname": "microsoft/TRELLIS.2-4B", + "backend": "flash_attn", + "device": "cuda", + "low_vram": true, + "keep_models_loaded": false, + "conv_backend": "flex_gemm", + "sparse_backend": "flash_attn", + "use_reconviagen": false + }, + "class_type": "Trellis2LoadModel", + "_meta": { + "title": "Trellis2 - LoadModel" + } + }, + "161": { + "inputs": { + "remesh_band": 1, + "resolution": 1024, + "remove_floaters": true, + "remove_inner_faces": true, + "mesh": [ + "217", + 0 + ] + }, + "class_type": "Trellis2ReconstructMeshWithQuad", + "_meta": { + "title": "Trellis2 - Reconstruct Mesh With Quad" + } + }, + "194": { + "inputs": { + "padding": 10, + "remove_background": false, + "max_size": 1024, + "image": [ + "6", + 2 + ] + }, + "class_type": "Trellis2PreProcessImage", + "_meta": { + "title": "Trellis2 - PreProcess Image" + } + }, + "202": { + "inputs": { + "reorient_vertices": "90 degrees", + "mesh": [ + "259", + 0 + ] + }, + "class_type": "Trellis2MeshWithVoxelToTrimesh", + "_meta": { + "title": "Trellis2 - Mesh With Voxel To Trimesh" + } + }, + "203": { + "inputs": { + "filename_prefix": [ + "219", + 0 + ], + "file_format": "glb", + "trimesh": [ + "202", + 0 + ] + }, + "class_type": "Trellis2ExportMesh", + "_meta": { + "title": "Trellis2 - Export Mesh" + } + }, + "209": { + "inputs": { + "value": 500000 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Target Face Number" + } + }, + "213": { + "inputs": { + "max_views": 1, + "pipeline": [ + "39", + 0 + ], + "image": [ + "194", + 0 + ] + }, + "class_type": "Trellis2ImageCondGenerator", + "_meta": { + "title": "Trellis2 - ImageCond Generator" + } + }, + "214": { + "inputs": { + "seed": 304843910, + "sparse_structure_steps": 25, + "sparse_structure_guidance_strength": 7.5, + "sparse_structure_guidance_rescale": 0.7, + "sparse_structure_rescale_t": 5, + "sparse_structure_sampler": "heun", + "sparse_structure_resolution": 32, + "sparse_structure_guidance_interval_start": 0.6, + "sparse_structure_guidance_interval_end": 1, + "fill_holes": true, + "hole_iterations": 1, + "verbose": false, + "dino_lock": 0.65, + "dino_substeps": 2, + "hole_fill_algorithm": "flood_fill", + "dino_foundation_cap": 0.92, + "keep_only_shell": true, + "pipeline": [ + "213", + 2 + ], + "image_cond": [ + "213", + 0 + ] + }, + "class_type": "Trellis2SparseGenerator", + "_meta": { + "title": "Trellis2 - Sparse Generator" + } + }, + "215": { + "inputs": { + "resolution": 512, + "shape_steps": 12, + "shape_guidance_strength": 7.5, + "shape_guidance_rescale": 0.5, + "shape_rescale_t": 3, + "shape_sampler": "heun", + "shape_guidance_interval_start": 0.1, + "shape_guidance_interval_end": 1, + "verbose": false, + "dino_lock": 0.65, + "dino_substeps": 2, + "dino_foundation_cap": 0.92, + "pipeline": [ + "214", + 2 + ], + "image_cond": [ + "213", + 0 + ], + "coords": [ + "214", + 0 + ] + }, + "class_type": "Trellis2ShapeGenerator", + "_meta": { + "title": "Trellis2 - Shape Generator" + } + }, + "217": { + "inputs": { + "resolution": [ + "258", + 1 + ], + "use_tiled_decoder": true, + "pipeline": [ + "258", + 2 + ], + "shape_slat": [ + "258", + 0 + ] + }, + "class_type": "Trellis2DecodeLatents", + "_meta": { + "title": "Trellis2 - Decode Latents" + } + }, + "218": { + "inputs": { + "target_face_num": [ + "209", + 0 + ], + "method": "Cumesh", + "mesh": [ + "161", + 0 + ] + }, + "class_type": "Trellis2SimplifyMesh", + "_meta": { + "title": "Trellis2 - Simplify Mesh" + } + }, + "219": { + "inputs": { + "value": "LionShield" + }, + "class_type": "PrimitiveString", + "_meta": { + "title": "Name" + } + }, + "232": { + "inputs": { + "model_file": [ + "203", + 0 + ], + "image": "" + }, + "class_type": "Preview3D", + "_meta": { + "title": "Preview 3D & Animation" + } + }, + "258": { + "inputs": { + "from_resolution": [ + "215", + 1 + ], + "to_resolution": 1024, + "sparse_structure_resolution": 32, + "max_num_tokens": 999999, + "shape_steps": 12, + "shape_guidance_strength": 7.5, + "shape_guidance_rescale": 0.5, + "shape_rescale_t": 3, + "shape_sampler": "heun", + "shape_guidance_interval_start": 0.6, + "shape_guidance_interval_end": 1, + "verbose": false, + "dino_lock": 0.65, + "dino_substeps": 2, + "dino_foundation_cap": 0.92, + "pipeline": [ + "215", + 2 + ], + "image_cond": [ + "213", + 1 + ], + "shape_slat": [ + "215", + 0 + ] + }, + "class_type": "Trellis2ShapeCascadeGenerator", + "_meta": { + "title": "Trellis2 - Shape Cascade Generator" + } + }, + "259": { + "inputs": { + "mesh": [ + "218", + 0 + ] + }, + "class_type": "Trellis2FillHolesWithMeshlib", + "_meta": { + "title": "Trellis2 - Fill Holes with Meshlib" + } + } +} \ No newline at end of file diff --git a/setup/Mesh Projection TexturedView with QwenImageEdit.json b/setup/Mesh Projection TexturedView with QwenImageEdit.json new file mode 100644 index 0000000..578dc22 --- /dev/null +++ b/setup/Mesh Projection TexturedView with QwenImageEdit.json @@ -0,0 +1,429 @@ +{ + "1": { + "inputs": { + "shift": 3.1, + "model": [ + "13", + 0 + ] + }, + "class_type": "ModelSamplingAuraFlow", + "_meta": { + "title": "ModelSamplingAuraFlow" + } + }, + "2": { + "inputs": { + "tile_size": 128, + "overlap": 64, + "temporal_size": 64, + "temporal_overlap": 8, + "samples": [ + "20", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEDecodeTiled", + "_meta": { + "title": "VAE Decode (Tiled)" + } + }, + "3": { + "inputs": { + "conditioning": [ + "9", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "4": { + "inputs": { + "pixels": [ + "38", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "5": { + "inputs": { + "strength": 1, + "pre_cfg": false, + "model": [ + "1", + 0 + ] + }, + "class_type": "CFGNorm", + "_meta": { + "title": "CFGNorm" + } + }, + "6": { + "inputs": { + "width": [ + "34", + 0 + ], + "height": [ + "34", + 0 + ], + "batch_size": 1 + }, + "class_type": "EmptyLatentImage", + "_meta": { + "title": "Empty Latent Image" + } + }, + "7": { + "inputs": { + "conditioning": [ + "8", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "8": { + "inputs": { + "prompt": "", + "clip": [ + "14", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus (Positive)" + } + }, + "9": { + "inputs": { + "prompt": "", + "clip": [ + "14", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus" + } + }, + "10": { + "inputs": { + "conditioning": [ + "7", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "11": { + "inputs": { + "conditioning": [ + "3", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "12": { + "inputs": { + "pixels": [ + "28", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "13": { + "inputs": { + "lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", + "strength_model": 1, + "model": [ + "19", + 0 + ] + }, + "class_type": "LoraLoaderModelOnly", + "_meta": { + "title": "Load LoRA" + } + }, + "14": { + "inputs": { + "clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors", + "type": "qwen_image", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "15": { + "inputs": { + "vae_name": "qwen_image_vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "19": { + "inputs": { + "unet_name": "{diffusion_model}" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "20": { + "inputs": { + "seed": 1000, + "steps": 4, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1, + "model": [ + "5", + 0 + ], + "positive": [ + "10", + 0 + ], + "negative": [ + "11", + 0 + ], + "latent_image": [ + "6", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "21": { + "inputs": { + "image": "" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Position Image" + } + }, + "22": { + "inputs": { + "image": "" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Reference Image" + } + }, + "25": { + "inputs": { + "value": 1, + "width": 1024, + "height": 1024 + }, + "class_type": "SolidMask", + "_meta": { + "title": "SolidMask" + } + }, + "26": { + "inputs": { + "mask": [ + "22", + 1 + ] + }, + "class_type": "InvertMask", + "_meta": { + "title": "InvertMask" + } + }, + "27": { + "inputs": { + "mask": [ + "25", + 0 + ] + }, + "class_type": "MaskToImage", + "_meta": { + "title": "Convert Mask to Image" + } + }, + "28": { + "inputs": { + "x": 0, + "y": 0, + "resize_source": false, + "destination": [ + "27", + 0 + ], + "source": [ + "22", + 0 + ], + "mask": [ + "26", + 0 + ] + }, + "class_type": "ImageCompositeMasked", + "_meta": { + "title": "ImageCompositeMasked" + } + }, + "34": { + "inputs": { + "value": 1024 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Image Resolution" + } + }, + "35": { + "inputs": { + "filename_prefix": "Qwen", + "images": [ + "36", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "36": { + "inputs": { + "model": "RMBG-2.0", + "sensitivity": 1, + "process_res": 1024, + "mask_blur": 0, + "mask_offset": -1, + "invert_output": false, + "refine_foreground": false, + "background": "Alpha", + "background_color": "#222222", + "image": [ + "2", + 0 + ] + }, + "class_type": "RMBG", + "_meta": { + "title": "Remove Background (RMBG)" + } + }, + "37": { + "inputs": { + "image": "" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Textured View" + } + }, + "38": { + "inputs": { + "blend_factor": 1, + "blend_mode": "screen", + "image1": [ + "37", + 0 + ], + "image2": [ + "39", + 0 + ] + }, + "class_type": "ImageBlend", + "_meta": { + "title": "Blend Images" + } + }, + "39": { + "inputs": { + "low_threshold": 0.05, + "high_threshold": 0.25, + "image": [ + "21", + 0 + ] + }, + "class_type": "Canny", + "_meta": { + "title": "Canny" + } + } +} \ No newline at end of file diff --git a/setup/Mesh Projection with QwenImageEdit.json b/setup/Mesh Projection with QwenImageEdit.json new file mode 100644 index 0000000..3e93e19 --- /dev/null +++ b/setup/Mesh Projection with QwenImageEdit.json @@ -0,0 +1,402 @@ +{ + "1": { + "inputs": { + "shift": 3.1, + "model": [ + "13", + 0 + ] + }, + "class_type": "ModelSamplingAuraFlow", + "_meta": { + "title": "ModelSamplingAuraFlow" + } + }, + "2": { + "inputs": { + "tile_size": 128, + "overlap": 64, + "temporal_size": 64, + "temporal_overlap": 8, + "samples": [ + "20", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEDecodeTiled", + "_meta": { + "title": "VAE Decode (Tiled)" + } + }, + "3": { + "inputs": { + "conditioning": [ + "9", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "4": { + "inputs": { + "pixels": [ + "33", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "5": { + "inputs": { + "strength": 1, + "pre_cfg": false, + "model": [ + "1", + 0 + ] + }, + "class_type": "CFGNorm", + "_meta": { + "title": "CFGNorm" + } + }, + "6": { + "inputs": { + "width": [ + "34", + 0 + ], + "height": [ + "34", + 0 + ], + "batch_size": 1 + }, + "class_type": "EmptyLatentImage", + "_meta": { + "title": "Empty Latent Image" + } + }, + "7": { + "inputs": { + "conditioning": [ + "8", + 0 + ], + "latent": [ + "12", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "8": { + "inputs": { + "prompt": "Draw the front view", + "clip": [ + "14", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus (Positive)" + } + }, + "9": { + "inputs": { + "prompt": "", + "clip": [ + "14", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "TextEncodeQwenImageEditPlus", + "_meta": { + "title": "TextEncodeQwenImageEditPlus" + } + }, + "10": { + "inputs": { + "conditioning": [ + "7", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "11": { + "inputs": { + "conditioning": [ + "3", + 0 + ], + "latent": [ + "4", + 0 + ] + }, + "class_type": "ReferenceLatent", + "_meta": { + "title": "ReferenceLatent" + } + }, + "12": { + "inputs": { + "pixels": [ + "28", + 0 + ], + "vae": [ + "15", + 0 + ] + }, + "class_type": "VAEEncode", + "_meta": { + "title": "VAE Encode" + } + }, + "13": { + "inputs": { + "lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", + "strength_model": 1, + "model": [ + "19", + 0 + ] + }, + "class_type": "LoraLoaderModelOnly", + "_meta": { + "title": "Load LoRA" + } + }, + "14": { + "inputs": { + "clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors", + "type": "qwen_image", + "device": "default" + }, + "class_type": "CLIPLoader", + "_meta": { + "title": "Load CLIP" + } + }, + "15": { + "inputs": { + "vae_name": "qwen_image_vae.safetensors" + }, + "class_type": "VAELoader", + "_meta": { + "title": "Load VAE" + } + }, + "19": { + "inputs": { + "unet_name": "{diffusion_model}" + }, + "class_type": "UnetLoaderGGUF", + "_meta": { + "title": "Unet Loader (GGUF)" + } + }, + "20": { + "inputs": { + "seed": 1000, + "steps": 4, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1, + "model": [ + "5", + 0 + ], + "positive": [ + "10", + 0 + ], + "negative": [ + "11", + 0 + ], + "latent_image": [ + "6", + 0 + ] + }, + "class_type": "KSampler", + "_meta": { + "title": "KSampler" + } + }, + "21": { + "inputs": { + "image": "" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Position Image" + } + }, + "22": { + "inputs": { + "image": "" + }, + "class_type": "LoadImage", + "_meta": { + "title": "Reference Image" + } + }, + "25": { + "inputs": { + "value": 1, + "width": 1024, + "height": 1024 + }, + "class_type": "SolidMask", + "_meta": { + "title": "SolidMask" + } + }, + "26": { + "inputs": { + "mask": [ + "22", + 1 + ] + }, + "class_type": "InvertMask", + "_meta": { + "title": "InvertMask" + } + }, + "27": { + "inputs": { + "mask": [ + "25", + 0 + ] + }, + "class_type": "MaskToImage", + "_meta": { + "title": "Convert Mask to Image" + } + }, + "28": { + "inputs": { + "x": 0, + "y": 0, + "resize_source": false, + "destination": [ + "27", + 0 + ], + "source": [ + "22", + 0 + ], + "mask": [ + "26", + 0 + ] + }, + "class_type": "ImageCompositeMasked", + "_meta": { + "title": "ImageCompositeMasked" + } + }, + "33": { + "inputs": { + "low_threshold": 0.05, + "high_threshold": 0.25, + "image": [ + "21", + 0 + ] + }, + "class_type": "Canny", + "_meta": { + "title": "Canny" + } + }, + "34": { + "inputs": { + "value": 1024 + }, + "class_type": "PrimitiveInt", + "_meta": { + "title": "Image Resolution" + } + }, + "35": { + "inputs": { + "filename_prefix": "Qwen", + "images": [ + "36", + 0 + ] + }, + "class_type": "SaveImage", + "_meta": { + "title": "Save Image" + } + }, + "36": { + "inputs": { + "model": "RMBG-2.0", + "sensitivity": 1, + "process_res": 1024, + "mask_blur": 0, + "mask_offset": -1, + "invert_output": false, + "refine_foreground": false, + "background": "Alpha", + "background_color": "#222222", + "image": [ + "2", + 0 + ] + }, + "class_type": "RMBG", + "_meta": { + "title": "Remove Background (RMBG)" + } + } +} \ No newline at end of file diff --git a/setup/setup.json b/setup/setup.json new file mode 100644 index 0000000..3884bf3 --- /dev/null +++ b/setup/setup.json @@ -0,0 +1,145 @@ +{ + "ComfyUIPaths": { + "DiffusionModels": "models/diffusion_models", + "VAE": "models/vae", + "TextEncoder": "models/text_encoders", + "LoRA": "models/loras" + }, + "DiffusionModels": [ + { + "Name": "Qwen Image Edit 2511", + "Models": { + "F16": { "FileName": "qwen-image-edit-2511-F16.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-F16.gguf?download=true", "Size": 40.9 }, + "BF16": { "FileName": "qwen-image-edit-2511-BF16.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-BF16.gguf?download=true", "Size": 40.9 }, + "Q8": { "FileName": "qwen-image-edit-2511-Q8_0.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q8_0.gguf?download=true", "Size": 21.8 }, + "Q6": { "FileName": "qwen-image-edit-2511-Q6_K.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q6_K.gguf?download=true", "Size": 16.9 }, + "Q5": { "FileName": "qwen-image-edit-2511-Q5_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q5_K_M.gguf?download=true", "Size": 15.0 }, + "Q4": { "FileName": "qwen-image-edit-2511-Q4_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q4_K_M.gguf?download=true", "Size": 13.2 }, + "Q3": { "FileName": "qwen-image-edit-2511-Q3_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q3_K_M.gguf?download=true", "Size": 9.9 }, + "Q2": { "FileName": "qwen-image-edit-2511-Q2_K.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q2_K.gguf?download=true", "Size": 7.5 } + }, + "VAE": { "FileName": "qwen_image_vae.safetensors", "Url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors?download=true", "Size": 0.3 }, + "TextEncoder": { "FileName": "qwen_2.5_vl_7b_fp8_scaled.safetensors", "Url": "https://huggingface.co/Comfy-Org/HunyuanVideo_1.5_repackaged/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors?download=true", "Size": 9.4 }, + "LoRA": { "FileName": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", "Url": "https://huggingface.co/lightx2v/Qwen-Image-Edit-2511-Lightning/resolve/main/Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors?download=true", "Size": 0.9 }, + "Workflows": [ + { + "Name": "Mesh Projection with QwenImageEdit", + "File": "setup/Mesh Projection with QwenImageEdit.json", + "Inputs": [ + { "Node": "21", "Input": "image", "Name": "Position Image", "Type": "Image" }, + { "Node": "22", "Input": "image", "Name": "Reference Image", "Type": "Image" }, + { "Node": "8", "Input": "prompt", "Name": "Prompt", "Type": "String" }, + { "Node": "20", "Input": "seed", "Name": "Seed", "Type": "Number" }, + { "Node": "34", "Input": "value", "Name": "Image Resolution", "Type": "Number" } + ], + "Outputs": [ + { "Node": "35", "Name": "Save Image", "Type": "Image" } + ] + }, + { + "Name": "Mesh Projection TexturedView with QwenImageEdit", + "File": "setup/Mesh Projection TexturedView with QwenImageEdit.json", + "Inputs": [ + { "Node": "21", "Input": "image", "Name": "Position Image", "Type": "Image" }, + { "Node": "22", "Input": "image", "Name": "Reference Image", "Type": "Image" }, + { "Node": "37", "Input": "image", "Name": "Textured View", "Type": "Image" }, + { "Node": "8", "Input": "prompt", "Name": "Prompt", "Type": "String" }, + { "Node": "20", "Input": "seed", "Name": "Seed", "Type": "Number" }, + { "Node": "34", "Input": "value", "Name": "Image Resolution", "Type": "Number" } + ], + "Outputs": [ + { "Node": "35", "Name": "Save Image", "Type": "Image" } + ] + } + ] + }, + { + "Name": "Qwen Image 2512", + "Models": { + "F16": { "FileName": "qwen-image-2512-F16.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-F16.gguf?download=true", "Size": 40.9 }, + "BF16": { "FileName": "qwen-image-2512-BF16.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-BF16.gguf?download=true", "Size": 40.9 }, + "Q8": { "FileName": "qwen-image-2512-Q8_0.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q8_0.gguf?download=true", "Size": 21.8 }, + "Q6": { "FileName": "qwen-image-2512-Q6_K.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q6_K.gguf?download=true", "Size": 16.8 }, + "Q5": { "FileName": "qwen-image-2512-Q5_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q5_K_M.gguf?download=true", "Size": 15.0 }, + "Q4": { "FileName": "qwen-image-2512-Q4_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q4_K_M.gguf?download=true", "Size": 13.2 }, + "Q3": { "FileName": "qwen-image-2512-Q3_K_M.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q3_K_M.gguf?download=true", "Size": 9.9 }, + "Q2": { "FileName": "qwen-image-2512-Q2_K.gguf", "Url": "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q2_K.gguf?download=true", "Size": 7.3 } + }, + "VAE": { "FileName": "qwen_image_vae.safetensors", "Url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors?download=true", "Size": 0.3 }, + "TextEncoder": { "FileName": "qwen_2.5_vl_7b_fp8_scaled.safetensors", "Url": "https://huggingface.co/Comfy-Org/HunyuanVideo_1.5_repackaged/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors?download=true", "Size": 9.4 }, + "LoRA": { "FileName": "Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors", "Url": "https://huggingface.co/lightx2v/Qwen-Image-2512-Lightning/resolve/main/Qwen-Image-2512-Lightning-4steps-V1.0-bf16.safetensors?download=true", "Size": 0.9 }, + "Workflows": [ + { + "Name": "Gen Image with Qwen 2512", + "File": "setup/Gen Image with QwenImage2512.json", + "Inputs": [ + { "Node": "112", "Input": "text", "Name": "Prompt", "Type": "String" }, + { "Node": "116", "Input": "seed", "Name": "Seed", "Type": "Number" }, + { "Node": "116", "Input": "steps", "Name": "Steps", "Type": "Number" } + ], + "Outputs": [ + { "Node": "90", "Name": "Save Image", "Type": "Image" } + ] + } + ] + }, + { + "Name": "Flux 2 Dev", + "Models": { + "F16": { "FileName": "flux2-dev-F16.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-F16.gguf?download=true", "Size": 64.4 }, + "BF16": { "FileName": "flux2-dev-BF16.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-BF16.gguf?download=true", "Size": 64.4 }, + "Q8": { "FileName": "flux2-dev-Q8_0.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q8_0.gguf?download=true", "Size": 35.0 }, + "Q6": { "FileName": "flux2-dev-Q6_K.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q6_K.gguf?download=true", "Size": 27.4 }, + "Q5": { "FileName": "flux2-dev-Q5_K_M.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q5_K_M.gguf?download=true", "Size": 23.9 }, + "Q4": { "FileName": "flux2-dev-Q4_K_M.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q4_K_M.gguf?download=true", "Size": 20.0 }, + "Q3": { "FileName": "flux2-dev-Q3_K_M.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q3_K_M.gguf?download=true", "Size": 15.8 }, + "Q2": { "FileName": "flux2-dev-Q2_K.gguf", "Url": "https://huggingface.co/unsloth/FLUX.2-dev-GGUF/resolve/main/flux2-dev-Q2_K.gguf?download=true", "Size": 12.9 } + }, + "VAE": { "FileName": "flux2-vae.safetensors", "Url": "https://huggingface.co/Comfy-Org/flux2-dev/resolve/main/split_files/vae/flux2-vae.safetensors?download=true", "Size": 0.3 }, + "TextEncoder": { "FileName": "mistral_3_small_flux2_fp4_mixed.safetensors", "Url": "https://huggingface.co/Comfy-Org/flux2-dev/resolve/main/split_files/text_encoders/mistral_3_small_flux2_fp4_mixed.safetensors?download=true", "Size": 12.3 }, + "Workflows": [ + { + "Name": "Gen Image with Flux2 Dev", + "File": "setup/Gen Image with Flux2Dev.json", + "Inputs": [ + { "Node": "96", "Input": "text", "Name": "Prompt", "Type": "String" }, + { "Node": "92", "Input": "noise_seed", "Name": "Seed", "Type": "Number" }, + { "Node": "85", "Input": "steps", "Name": "Steps", "Type": "Number" } + ], + "Outputs": [ + { "Node": "9", "Name": "Save Image", "Type": "Image" } + ] + } + ] + }, + { + "Name": "Z-Image Turbo", + "Models": { + "F16": { "FileName": "z-image-turbo-F16.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-F16.gguf?download=true", "Size": 12.3 }, + "BF16": { "FileName": "z-image-turbo-BF16.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-BF16.gguf?download=true", "Size": 12.3 }, + "Q8": { "FileName": "z-image-turbo-Q8_0.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q8_0.gguf?download=true", "Size": 7.22 }, + "Q6": { "FileName": "z-image-turbo-Q6_K.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q6_K.gguf?download=true", "Size": 5.91 }, + "Q5": { "FileName": "z-image-turbo-Q5_K_M.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q5_K_M.gguf?download=true", "Size": 5.6 }, + "Q4": { "FileName": "z-image-turbo-Q4_K_M.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q4_K_M.gguf?download=true", "Size": 5.0 }, + "Q3": { "FileName": "z-image-turbo-Q3_K_M.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q3_K_M.gguf?download=true", "Size": 4.2 }, + "Q2": { "FileName": "z-image-turbo-Q2_K.gguf", "Url": "https://huggingface.co/unsloth/Z-Image-Turbo-GGUF/resolve/main/z-image-turbo-Q2_K.gguf?download=true", "Size": 3.6 } + }, + "VAE": { "FileName": "ae.safetensors", "Url": "https://huggingface.co/black-forest-labs/FLUX.2-dev/resolve/main/ae.safetensors?download=true", "Size": 0.3 }, + "TextEncoder": { "FileName": "qwen_3_4b_fp8_mixed.safetensors", "Url": "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b_fp8_mixed.safetensors?download=true", "Size": 5.6 }, + "Workflows": [ + { + "Name": "Gen Image with Z Image Turbo", + "File": "setup/Gen Image with ZImageTurbo.json", + "Inputs": [ + { "Node": "34:27", "Input": "text", "Name": "Prompt", "Type": "String" }, + { "Node": "34:3", "Input": "seed", "Name": "Seed", "Type": "Number" }, + { "Node": "34:3", "Input": "steps", "Name": "Steps", "Type": "Number" } + ], + "Outputs": [ + { "Node": "43", "Name": "Save Image", "Type": "Image" } + ] + } + ] + } + ] +} diff --git a/src/components/SetupWizardModal.css b/src/components/SetupWizardModal.css new file mode 100644 index 0000000..c4e2e4a --- /dev/null +++ b/src/components/SetupWizardModal.css @@ -0,0 +1,286 @@ +.setup-wizard { + max-width: 640px; +} + +.setup-wizard__steps { + list-style: none; + display: flex; + align-items: center; + gap: 0.5rem; + padding: 0 0 1.25rem; + margin: 0 0 1rem; + border-bottom: 1px solid rgba(71, 72, 74, 0.12); +} + +.setup-wizard__step { + display: flex; + align-items: center; + gap: 0.5rem; + font-size: 0.75rem; + color: var(--on-surface-variant); + flex: 1; + position: relative; +} + +.setup-wizard__step + .setup-wizard__step::before { + content: ''; + position: absolute; + left: -0.5rem; + right: calc(100% - 0.25rem); + height: 1px; + background: rgba(71, 72, 74, 0.18); +} + +.setup-wizard__step-index { + display: inline-flex; + align-items: center; + justify-content: center; + width: 22px; + height: 22px; + border-radius: 999px; + background: var(--surface-container-highest); + font-family: var(--font-label); + font-size: 0.7rem; + color: var(--on-surface-variant); + flex-shrink: 0; +} + +.setup-wizard__step--active .setup-wizard__step-index { + background: var(--primary); + color: var(--on-primary); +} + +.setup-wizard__step--done .setup-wizard__step-index { + background: rgba(143, 245, 255, 0.16); + color: var(--primary); +} + +.setup-wizard__step--active .setup-wizard__step-label { + color: var(--on-surface); + font-weight: 600; +} + +.setup-wizard__body { + display: flex; + flex-direction: column; + gap: 1rem; + position: relative; +} + +.setup-wizard__path-row { + display: flex; + align-items: stretch; + gap: 0.5rem; +} + +.setup-wizard__path-input { + flex: 1; + min-width: 0; +} + +.setup-wizard__browse-btn { + display: inline-flex; + align-items: center; + gap: 0.375rem; + padding: 0 0.875rem; + background: var(--surface-container-highest); + color: var(--on-surface); + border: 1px solid rgba(71, 72, 74, 0.18); + border-radius: var(--radius-lg); + font-family: var(--font-headline); + font-size: 0.8rem; + font-weight: 600; + cursor: pointer; + transition: all var(--transition-base); + white-space: nowrap; + flex-shrink: 0; +} + +.setup-wizard__browse-btn:hover:not(:disabled) { + border-color: rgba(143, 245, 255, 0.35); + color: var(--primary); + background: rgba(143, 245, 255, 0.05); +} + +.setup-wizard__browse-btn:disabled { + opacity: 0.6; + cursor: not-allowed; +} + +.setup-wizard__hint { + font-size: 0.75rem; + color: var(--on-surface-variant); + line-height: 1.5; + margin: 0; +} + +.setup-wizard__hint code { + font-family: var(--font-label); + background: var(--surface-container-highest); + padding: 0.05rem 0.3rem; + border-radius: var(--radius-sm); + font-size: 0.72rem; +} + +.setup-wizard__error { + font-size: 0.75rem; + color: var(--error); + background: var(--error-container); + border-radius: var(--radius-md); + padding: 0.625rem 0.75rem; + line-height: 1.4; +} + +.setup-wizard__model-list { + display: flex; + flex-direction: column; + gap: 0.75rem; + max-height: 360px; + overflow-y: auto; + padding-right: 6px; + + scrollbar-width: thin; + scrollbar-color: var(--outline) transparent; +} + +.setup-wizard__model-list::-webkit-scrollbar { width: 5px; } +.setup-wizard__model-list::-webkit-scrollbar-track { background: transparent; } +.setup-wizard__model-list::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 10px; } + +.setup-wizard__model-card { + padding: 0.875rem 1rem; + background: rgba(18, 19, 22, 0.45); + border: 1px solid rgba(71, 72, 74, 0.12); + border-radius: var(--radius-lg); + display: flex; + flex-direction: column; + gap: 0.625rem; +} + +.setup-wizard__model-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; +} + +.setup-wizard__model-name { + font-size: 0.9rem; + color: var(--on-surface); +} + +.setup-wizard__model-meta { + font-size: 0.7rem; + color: var(--on-surface-variant); + font-family: var(--font-label); +} + +.setup-wizard__summary { + display: flex; + align-items: center; + justify-content: space-between; + padding: 0.75rem 1rem; + background: rgba(143, 245, 255, 0.05); + border: 1px solid rgba(143, 245, 255, 0.18); + border-radius: var(--radius-md); + font-size: 0.8rem; + color: var(--on-surface); +} + +.setup-wizard__progress-block { + display: flex; + flex-direction: column; + gap: 0.5rem; + padding: 1rem; + background: rgba(18, 19, 22, 0.45); + border-radius: var(--radius-lg); + border: 1px solid rgba(71, 72, 74, 0.12); +} + +.setup-wizard__progress-meta, +.setup-wizard__progress-foot { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + font-size: 0.75rem; + color: var(--on-surface-variant); +} + +.setup-wizard__progress-file { + color: var(--on-surface); + font-family: var(--font-label); + word-break: break-all; +} + +.setup-wizard__progress-bar { + position: relative; + height: 8px; + width: 100%; + background: var(--surface-container-highest); + border-radius: var(--radius-full); + overflow: hidden; +} + +.setup-wizard__progress-bar-fill { + height: 100%; + background: linear-gradient(90deg, var(--primary), var(--secondary)); + transition: width 0.2s ease; +} + +.setup-wizard__workflow-list { + list-style: none; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + gap: 0.375rem; +} + +.setup-wizard__workflow-list li { + display: flex; + align-items: center; + gap: 0.5rem; + font-size: 0.8rem; + color: var(--on-surface); + padding: 0.5rem 0.75rem; + background: rgba(18, 19, 22, 0.45); + border-radius: var(--radius-md); + border: 1px solid rgba(71, 72, 74, 0.12); +} + +.setup-wizard__workflow-list .material-symbols-outlined { + font-size: 16px; + color: var(--secondary); +} + +.setup-wizard__result { + font-size: 0.8rem; + color: var(--on-surface); + padding: 0.75rem 1rem; + border-radius: var(--radius-md); + background: rgba(18, 19, 22, 0.45); + border: 1px solid rgba(71, 72, 74, 0.12); +} + +.setup-wizard__result-errors { + margin: 0.5rem 0 0; + padding-left: 1rem; + color: var(--error); + font-size: 0.72rem; +} + +.setup-wizard__actions { + display: flex; + gap: 0.75rem; + padding-top: 0.5rem; +} + +.setup-wizard__actions > button { + flex: 1; +} + +.setup-wizard__btn-skip { + flex: 0 0 auto; + min-width: 96px; +} diff --git a/src/components/SetupWizardModal.jsx b/src/components/SetupWizardModal.jsx new file mode 100644 index 0000000..9906017 --- /dev/null +++ b/src/components/SetupWizardModal.jsx @@ -0,0 +1,582 @@ +import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useSettings } from '../context/SettingsContext.shared' +import './SetupWizardModal.css' + +const API_BASE = 'http://localhost:3001/api' + +const STEPS = [ + { id: 'comfy-path', label: 'ComfyUI' }, + { id: 'models', label: 'Models' }, + { id: 'download', label: 'Download' }, + { id: 'workflows', label: 'Workflows' } +] + +function formatGB(bytes) { + if (!Number.isFinite(bytes) || bytes <= 0) return '0 GB' + return `${(bytes / (1024 ** 3)).toFixed(bytes >= 10 * 1024 ** 3 ? 0 : 1)} GB` +} + +function bytesFromGB(gb) { + const value = Number(gb) + return Number.isFinite(value) ? Math.round(value * (1024 ** 3)) : 0 +} + +function buildFileList(config, selections, comfyPathsByCategory) { + const map = new Map() + + const addFile = (relativeDir, entry) => { + if (!entry?.FileName || !entry?.Url) return + const key = `${relativeDir}::${entry.FileName}` + if (map.has(key)) return + map.set(key, { + relativeDir, + fileName: entry.FileName, + url: entry.Url, + expectedBytes: bytesFromGB(entry.Size) + }) + } + + for (const selection of selections) { + if (!selection.modelQuality) continue + const diffusion = (config.DiffusionModels || []).find(d => d.Name === selection.diffusionName) + if (!diffusion) continue + const modelEntry = diffusion.Models?.[selection.modelQuality] + addFile(comfyPathsByCategory.DiffusionModels, modelEntry) + addFile(comfyPathsByCategory.VAE, diffusion.VAE) + addFile(comfyPathsByCategory.TextEncoder, diffusion.TextEncoder) + if (diffusion.LoRA) { + addFile(comfyPathsByCategory.LoRA, diffusion.LoRA) + } + } + + return Array.from(map.values()) +} + +export default function SetupWizardModal({ onComplete, onClose }) { + const { settings, updateSettings } = useSettings() + + const [stepId, setStepId] = useState('comfy-path') + const [config, setConfig] = useState(null) + const [loadError, setLoadError] = useState('') + + const [comfyPath, setComfyPath] = useState('') + const [pathBusy, setPathBusy] = useState(false) + const [pathError, setPathError] = useState('') + const [browseBusy, setBrowseBusy] = useState(false) + + const [selectionByName, setSelectionByName] = useState({}) + const [existingFileKeys, setExistingFileKeys] = useState(new Set()) + const [checkingFiles, setCheckingFiles] = useState(false) + + const [downloadEvent, setDownloadEvent] = useState(null) + const [downloadError, setDownloadError] = useState('') + const eventSourceRef = useRef(null) + + const [installBusy, setInstallBusy] = useState(false) + const [installResult, setInstallResult] = useState(null) + + useEffect(() => { + let cancelled = false + ;(async () => { + try { + const res = await fetch(`${API_BASE}/setup/config`) + const data = await res.json() + if (cancelled) return + if (!res.ok) throw new Error(data?.error || 'Failed to load setup config') + setConfig(data) + const initial = {} + for (const diffusion of data.DiffusionModels || []) { + initial[diffusion.Name] = '' + } + setSelectionByName(initial) + } catch (err) { + if (!cancelled) setLoadError(err.message || String(err)) + } + })() + return () => { cancelled = true } + }, []) + + useEffect(() => { + setComfyPath(settings?.apis?.comfyui?.path || '') + }, [settings?.apis?.comfyui?.path]) + + useEffect(() => () => { + eventSourceRef.current?.close() + }, []) + + const allCandidateFiles = useMemo(() => { + if (!config) return [] + const paths = config.ComfyUIPaths || {} + const allSelections = (config.DiffusionModels || []).flatMap(diffusion => { + const qualities = Object.keys(diffusion.Models || {}) + return qualities.map(q => ({ diffusionName: diffusion.Name, modelQuality: q })) + }) + return buildFileList(config, allSelections, paths) + }, [config]) + + const refreshFileExistence = useCallback(async (pathOverride) => { + if (!config) return + const effectivePath = pathOverride ?? comfyPath + if (!effectivePath) return + + setCheckingFiles(true) + try { + const res = await fetch(`${API_BASE}/setup/check-files`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ comfyPath: effectivePath, files: allCandidateFiles }) + }) + const data = await res.json() + if (!res.ok) throw new Error(data?.error || 'Failed to check files') + const keys = new Set( + (data.files || []) + .filter(file => file.exists) + .map(file => `${file.relativeDir}::${file.fileName}`) + ) + setExistingFileKeys(keys) + } catch (err) { + console.error('Failed to check files:', err) + } finally { + setCheckingFiles(false) + } + }, [allCandidateFiles, comfyPath, config]) + + const selections = useMemo( + () => Object.entries(selectionByName).map(([diffusionName, modelQuality]) => ({ diffusionName, modelQuality })), + [selectionByName] + ) + + const filesToDownload = useMemo(() => { + if (!config) return [] + const candidates = buildFileList(config, selections, config.ComfyUIPaths || {}) + return candidates.filter(file => !existingFileKeys.has(`${file.relativeDir}::${file.fileName}`)) + }, [config, selections, existingFileKeys]) + + const totalDownloadBytes = useMemo( + () => filesToDownload.reduce((sum, file) => sum + (file.expectedBytes || 0), 0), + [filesToDownload] + ) + + const handleSkip = async () => { + try { + await updateSettings({ ...settings, initialSetupComplete: true }) + } catch (err) { + console.error('Failed to mark setup complete:', err) + } + onClose?.() + } + + const handleCloseAndMarkComplete = async () => { + try { + await updateSettings({ ...settings, initialSetupComplete: true }) + } catch (err) { + console.error('Failed to mark setup complete:', err) + } + onClose?.() + } + + const handleBrowseFolder = async () => { + setPathError('') + setBrowseBusy(true) + try { + const res = await fetch(`${API_BASE}/setup/pick-folder`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ description: 'Select your ComfyUI folder', initialPath: comfyPath }) + }) + const data = await res.json() + if (!res.ok) throw new Error(data?.error || 'Folder picker failed') + if (data.path) setComfyPath(data.path) + } catch (err) { + setPathError(err.message || String(err)) + } finally { + setBrowseBusy(false) + } + } + + const handleValidatePath = async () => { + setPathError('') + setPathBusy(true) + try { + const trimmed = comfyPath.trim() + const res = await fetch(`${API_BASE}/setup/check-comfy-path`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ path: trimmed }) + }) + const data = await res.json() + if (!res.ok) throw new Error(data?.error || 'Invalid ComfyUI path') + + await updateSettings({ + ...settings, + apis: { + ...(settings?.apis || {}), + comfyui: { ...(settings?.apis?.comfyui || {}), path: trimmed } + } + }) + + await refreshFileExistence(trimmed) + setStepId('models') + } catch (err) { + setPathError(err.message || String(err)) + } finally { + setPathBusy(false) + } + } + + const handleStartDownload = async () => { + setDownloadError('') + setDownloadEvent(null) + + if (filesToDownload.length === 0) { + setStepId('workflows') + return + } + + try { + const res = await fetch(`${API_BASE}/setup/download`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ comfyPath, files: filesToDownload }) + }) + const data = await res.json() + if (!res.ok) throw new Error(data?.error || 'Failed to start downloads') + + const jobId = data.jobId + setStepId('download') + + eventSourceRef.current?.close() + const source = new EventSource(`${API_BASE}/setup/download/progress/${jobId}`) + eventSourceRef.current = source + + source.onmessage = (event) => { + try { + const payload = JSON.parse(event.data) + setDownloadEvent(payload) + if (payload.status === 'done' || payload.status === 'error') { + source.close() + eventSourceRef.current = null + if (payload.status === 'error') { + setDownloadError(payload.error || 'Download failed') + } + } + } catch { + /* ignore */ + } + } + + source.onerror = () => { + source.close() + eventSourceRef.current = null + setDownloadError(prev => prev || 'Lost connection to download progress stream') + } + } catch (err) { + setDownloadError(err.message || String(err)) + } + } + + const handleInstallWorkflows = async () => { + setInstallBusy(true) + setInstallResult(null) + try { + const payloadSelections = selections.filter(s => s.modelQuality) + const res = await fetch(`${API_BASE}/setup/install-workflows`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ selections: payloadSelections }) + }) + const data = await res.json() + if (!res.ok) throw new Error(data?.error || 'Failed to install workflows') + setInstallResult(data) + } catch (err) { + setInstallResult({ installed: [], errors: [{ workflow: '*', error: err.message || String(err) }] }) + } finally { + setInstallBusy(false) + } + } + + const handleFinish = async () => { + try { + await updateSettings({ ...settings, initialSetupComplete: true }) + } catch (err) { + console.error('Failed to mark setup complete:', err) + } + onComplete?.() + } + + const downloadDone = downloadEvent?.status === 'done' + const downloadInProgress = downloadEvent?.status === 'downloading' + const overlayClick = stepId === 'comfy-path' ? handleCloseAndMarkComplete : undefined + + return ( +
+
e.stopPropagation()}> +
+ +
+
+

Initial Setup

+

+ Get ComfyUI wired up so you can generate locally. +

+
+ {stepId === 'comfy-path' && ( + + )} +
+ +
    + {STEPS.map((step, index) => { + const stepIndex = STEPS.findIndex(s => s.id === stepId) + const state = index < stepIndex ? 'done' : index === stepIndex ? 'active' : 'pending' + return ( +
  1. + {index + 1} + {step.label} +
  2. + ) + })} +
+ + {loadError &&
{loadError}
} + + {stepId === 'comfy-path' && ( +
+ +
+ setComfyPath(e.target.value)} + autoFocus + /> + +
+

+ The folder must contain a models subfolder. Missing model-type subfolders will be created. +

+ {pathError &&
{pathError}
} + +
+ + +
+
+ )} + + {stepId === 'models' && config && ( +
+

+ Pick one quality per model you want to install — or leave it as “Don’t install”. Sizes include the model file and its required VAE / Text Encoder / LoRA. +

+ +
+ {(config.DiffusionModels || []).map(diffusion => { + const currentQuality = selectionByName[diffusion.Name] || '' + const selectionFiles = buildFileList( + config, + [{ diffusionName: diffusion.Name, modelQuality: currentQuality }], + config.ComfyUIPaths || {} + ) + const selectionDownload = selectionFiles.filter( + file => !existingFileKeys.has(`${file.relativeDir}::${file.fileName}`) + ) + const selectionDownloadBytes = selectionDownload.reduce((sum, f) => sum + (f.expectedBytes || 0), 0) + + return ( +
+
+ {diffusion.Name} + {currentQuality && ( + + {selectionDownload.length === 0 ? 'Already installed' : `${formatGB(selectionDownloadBytes)} to download`} + + )} +
+ +
+ + expand_more +
+
+ ) + })} +
+ +
+ {filesToDownload.length} file{filesToDownload.length === 1 ? '' : 's'} to download + {formatGB(totalDownloadBytes)} +
+ +
+ + +
+
+ )} + + {stepId === 'download' && ( +
+
+
+ + {downloadEvent?.currentFile || (downloadDone ? 'All files downloaded' : 'Preparing…')} + + + {downloadEvent + ? `${Math.min((downloadEvent.currentIndex || 0) + (downloadDone ? 0 : 1), downloadEvent.totalFiles || 0)} / ${downloadEvent.totalFiles || 0}` + : ''} + +
+ +
+
+
+ +
+ {downloadEvent?.overallPercent ?? 0}% overall + + {downloadInProgress && downloadEvent?.currentTotalBytes + ? `${formatGB(downloadEvent.currentBytes)} / ${formatGB(downloadEvent.currentTotalBytes)} (${downloadEvent.currentPercent ?? 0}%)` + : ''} + +
+
+ + {downloadError &&
{downloadError}
} + +
+ + +
+
+ )} + + {stepId === 'workflows' && ( +
+

+ Install the workflows for the models you selected. The downloaded diffusion model is wired into each workflow. +

+ +
    + {selections.filter(s => s.modelQuality).flatMap(sel => { + const diffusion = (config?.DiffusionModels || []).find(d => d.Name === sel.diffusionName) + return (diffusion?.Workflows || []).map(workflow => ( +
  • + graph_3 + {workflow.Name} +
  • + )) + })} +
+ + {installResult && ( +
+
Installed: {installResult.installed?.length || 0}
+ {installResult.errors?.length > 0 && ( +
    + {installResult.errors.map((e, i) => ( +
  • {e.workflow || e.diffusionName || 'error'}: {e.error}
  • + ))} +
+ )} +
+ )} + +
+ + {!installResult ? ( + + ) : ( + + )} +
+
+ )} +
+
+ ) +} diff --git a/src/context/SettingsContext.jsx b/src/context/SettingsContext.jsx index bfea33e..bc74120 100644 --- a/src/context/SettingsContext.jsx +++ b/src/context/SettingsContext.jsx @@ -26,6 +26,7 @@ function normalizeSettings(settings) { export function SettingsProvider({ children }) { const [settings, setSettings] = useState({ profile: { name: 'User', avatar: null }, + initialSetupComplete: false, apis: { google: { apiKey: '', diff --git a/src/pages/MeshEditorPage.jsx b/src/pages/MeshEditorPage.jsx index 698d8b4..7ee77bc 100644 --- a/src/pages/MeshEditorPage.jsx +++ b/src/pages/MeshEditorPage.jsx @@ -7464,7 +7464,7 @@ export default function MeshEditorPage() {
- +
+ + +
diff --git a/storage.js b/storage.js index ec53b3b..ba54dc9 100644 --- a/storage.js +++ b/storage.js @@ -46,6 +46,7 @@ export const DEFAULT_SETTINGS = { name: 'User', avatar: null }, + initialSetupComplete: false, apis: { google: { apiKey: '',