{ "id": "e3b87cb2-b90b-4cdc-b12d-d985e83201f5", "revision": 0, "last_node_id": 24, "last_link_id": 31, "nodes": [ { "id": 1, "type": "UNETLoader", "pos": [ -40, -500 ], "size": [ 340, 82 ], "flags": {}, "order": 1, "mode": 0, "inputs": [], "outputs": [ { "name": "MODEL", "type": "MODEL", "slot_index": 0, "links": [ 13 ] } ], "properties": { "Node name for S&R": "UNETLoader", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "flux-2-klein-9b.safetensors", "default" ], "title": "Load Flux2 Klein" }, { "id": 2, "type": "CLIPLoader", "pos": [ -40, -360 ], "size": [ 340, 110 ], "flags": {}, "order": 2, "mode": 0, "inputs": [], "outputs": [ { "name": "CLIP", "type": "CLIP", "slot_index": 0, "links": [ 9 ] } ], "properties": { "Node name for S&R": "CLIPLoader", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "qwen_3_8b_fp8mixed.safetensors", "flux2", "default" ] }, { "id": 3, "type": "VAELoader", "pos": [ -40, -200 ], "size": [ 340, 60 ], "flags": {}, "order": 3, "mode": 0, "inputs": [], "outputs": [ { "name": "VAE", "type": "VAE", "slot_index": 0, "links": [ 3, 25 ] } ], "properties": { "Node name for S&R": "VAELoader", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "flux2-vae.safetensors" ] }, { "id": 4, "type": "LoadImage", "pos": [ -40, -60 ], "size": [ 270, 330 ], "flags": {}, "order": 4, "mode": 0, "inputs": [], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [ 1, 4, 27, 29 ] }, { "name": "MASK", "type": "MASK", "slot_index": 0, "links": [] } ], "properties": { "Node name for S&R": "LoadImage", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "example.png", "image" ], "title": "Main Image" }, { "id": 5, "type": "ImageResizeKJ", "pos": [ 300, -60 ], "size": [ 300, 190 ], "flags": {}, "order": 5, "mode": 0, "inputs": [ { "name": "image", "type": "IMAGE", "link": 1 }, { "name": "get_image_size", "type": "IMAGE", "link": null, "shape": 7 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [ 2 ] }, { "name": "width", "type": "INT", "slot_index": 0, "links": [ 16 ] }, { "name": "height", "type": "INT", "slot_index": 0, "links": [ 17 ] } ], "properties": { "Node name for S&R": "ImageResizeKJ", "cnr_id": "comfyui-kjnodes", "aux_id": "kijai/ComfyUI-KJNodes", "ver": "1.2.5" }, "widgets_values": [ 0, 0, "lanczos", false, 16, "disabled" ], "title": "Fit to /16" }, { "id": 6, "type": "VAEEncode", "pos": [ 640, -60 ], "size": [ 210, 60 ], "flags": {}, "order": 6, "mode": 0, "inputs": [ { "name": "pixels", "type": "IMAGE", "link": 2 }, { "name": "vae", "type": "VAE", "link": 3 } ], "outputs": [ { "name": "LATENT", "type": "LATENT", "slot_index": 0, "links": [ 7, 11 ] } ], "properties": { "Node name for S&R": "VAEEncode", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [] }, { "id": 7, "type": "SAM3Segment", "pos": [ 300, 320 ], "size": [ 300, 320 ], "flags": {}, "order": 7, "mode": 0, "inputs": [ { "name": "image", "type": "IMAGE", "link": 4 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [] }, { "name": "MASK", "type": "MASK", "slot_index": 0, "links": [ 5, 6 ] }, { "name": "MASK_IMAGE", "type": "IMAGE", "slot_index": 0, "links": [] } ], "properties": { "Node name for S&R": "SAM3Segment", "cnr_id": "comfyui-rmbg", "aux_id": "1038lab/ComfyUI-RMBG", "ver": "3.0.0" }, "widgets_values": [ "person", "Merged", 0.5, 0, 0, 0, 0, "Auto", false, false, "Alpha", "#222222" ], "title": "Segment PERSON (SAM3)" }, { "id": 8, "type": "GrowMaskWithBlur", "pos": [ 640, 320 ], "size": [ 300, 250 ], "flags": {}, "order": 8, "mode": 0, "inputs": [ { "name": "mask", "type": "MASK", "link": 5 } ], "outputs": [ { "name": "mask", "type": "MASK", "slot_index": 0, "links": [] }, { "name": "mask_inverted", "type": "MASK", "slot_index": 0, "links": [ 8 ] } ], "properties": { "Node name for S&R": "GrowMaskWithBlur", "cnr_id": "comfyui-kjnodes", "aux_id": "kijai/ComfyUI-KJNodes", "ver": "1.2.5" }, "widgets_values": [ -4, 0.0, true, false, 8.0, 1.0, 1.0, true ], "title": "Background mask (inverted)" }, { "id": 9, "type": "SetLatentNoiseMask", "pos": [ 900, -60 ], "size": [ 240, 70 ], "flags": {}, "order": 9, "mode": 0, "inputs": [ { "name": "samples", "type": "LATENT", "link": 7 }, { "name": "mask", "type": "MASK", "link": 8 } ], "outputs": [ { "name": "LATENT", "type": "LATENT", "slot_index": 0, "links": [ 23 ] } ], "properties": { "Node name for S&R": "SetLatentNoiseMask", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [] }, { "id": 10, "type": "CLIPTextEncode", "pos": [ 300, -420 ], "size": [ 380, 160 ], "flags": {}, "order": 10, "mode": 0, "inputs": [ { "name": "clip", "type": "CLIP", "link": 9 } ], "outputs": [ { "name": "CONDITIONING", "type": "CONDITIONING", "slot_index": 0, "links": [ 10, 12 ] } ], "properties": { "Node name for S&R": "CLIPTextEncode", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "sharp photorealistic background, same scene, evenly lit, uniform soft lighting matching the subject, no added shadows, no vignetting, crisp focus, fine natural texture, clean detail, no blur, no artifacts, high detail, 4k" ], "title": "Background prompt" }, { "id": 11, "type": "ReferenceLatent", "pos": [ 700, -420 ], "size": [ 240, 70 ], "flags": {}, "order": 11, "mode": 0, "inputs": [ { "name": "conditioning", "type": "CONDITIONING", "link": 10 }, { "name": "latent", "type": "LATENT", "link": 11, "shape": 7 } ], "outputs": [ { "name": "CONDITIONING", "type": "CONDITIONING", "slot_index": 0, "links": [ 14 ] } ], "properties": { "Node name for S&R": "ReferenceLatent", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [] }, { "id": 12, "type": "ConditioningZeroOut", "pos": [ 700, -520 ], "size": [ 280, 50 ], "flags": {}, "order": 12, "mode": 0, "inputs": [ { "name": "conditioning", "type": "CONDITIONING", "link": 12 } ], "outputs": [ { "name": "CONDITIONING", "type": "CONDITIONING", "slot_index": 0, "links": [ 15 ] } ], "properties": { "Node name for S&R": "ConditioningZeroOut", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [], "title": "Negative (zeroed)" }, { "id": 13, "type": "CFGGuider", "pos": [ 1000, -420 ], "size": [ 280, 120 ], "flags": {}, "order": 13, "mode": 0, "inputs": [ { "name": "model", "type": "MODEL", "link": 13 }, { "name": "positive", "type": "CONDITIONING", "link": 14 }, { "name": "negative", "type": "CONDITIONING", "link": 15 } ], "outputs": [ { "name": "GUIDER", "type": "GUIDER", "slot_index": 0, "links": [ 20 ] } ], "properties": { "Node name for S&R": "CFGGuider", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ 1.0 ] }, { "id": 14, "type": "Flux2Scheduler", "pos": [ 1000, -240 ], "size": [ 280, 120 ], "flags": {}, "order": 14, "mode": 0, "inputs": [ { "name": "width", "type": "INT", "link": 16, "widget": { "name": "width" } }, { "name": "height", "type": "INT", "link": 17, "widget": { "name": "height" } } ], "outputs": [ { "name": "SIGMAS", "type": "SIGMAS", "slot_index": 0, "links": [ 18 ] } ], "properties": { "Node name for S&R": "Flux2Scheduler", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ 8, 1024, 1024 ] }, { "id": 24, "type": "SplitSigmasDenoise", "pos": [ 1000, -160 ], "size": [ 280, 90 ], "flags": {}, "order": 24, "mode": 0, "inputs": [ { "name": "sigmas", "type": "SIGMAS", "link": 18 } ], "outputs": [ { "name": "high_sigmas", "type": "SIGMAS", "slot_index": 0, "links": [] }, { "name": "low_sigmas", "type": "SIGMAS", "slot_index": 0, "links": [ 22 ] } ], "properties": { "Node name for S&R": "SplitSigmasDenoise", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ 1.0 ], "title": "partial denoise" }, { "id": 15, "type": "KSamplerSelect", "pos": [ 1000, -80 ], "size": [ 280, 60 ], "flags": {}, "order": 15, "mode": 0, "inputs": [], "outputs": [ { "name": "SAMPLER", "type": "SAMPLER", "slot_index": 0, "links": [ 21 ] } ], "properties": { "Node name for S&R": "KSamplerSelect", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "euler" ] }, { "id": 16, "type": "RandomNoise", "pos": [ 1000, 20 ], "size": [ 280, 90 ], "flags": {}, "order": 16, "mode": 0, "inputs": [], "outputs": [ { "name": "NOISE", "type": "NOISE", "slot_index": 0, "links": [ 19 ] } ], "properties": { "Node name for S&R": "RandomNoise", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ 156680208700286, "randomize" ] }, { "id": 17, "type": "SamplerCustomAdvanced", "pos": [ 1340, -420 ], "size": [ 300, 160 ], "flags": {}, "order": 17, "mode": 0, "inputs": [ { "name": "noise", "type": "NOISE", "link": 19 }, { "name": "guider", "type": "GUIDER", "link": 20 }, { "name": "sampler", "type": "SAMPLER", "link": 21 }, { "name": "sigmas", "type": "SIGMAS", "link": 22 }, { "name": "latent_image", "type": "LATENT", "link": 23 } ], "outputs": [ { "name": "output", "type": "LATENT", "slot_index": 0, "links": [ 24 ] }, { "name": "denoised_output", "type": "LATENT", "slot_index": 0, "links": [] } ], "properties": { "Node name for S&R": "SamplerCustomAdvanced", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [] }, { "id": 18, "type": "VAEDecode", "pos": [ 1680, -420 ], "size": [ 210, 50 ], "flags": {}, "order": 18, "mode": 0, "inputs": [ { "name": "samples", "type": "LATENT", "link": 24 }, { "name": "vae", "type": "VAE", "link": 25 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [ 26 ] } ], "properties": { "Node name for S&R": "VAEDecode", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [] }, { "id": 19, "type": "GrowMaskWithBlur", "pos": [ 640, 660 ], "size": [ 300, 250 ], "flags": {}, "order": 19, "mode": 0, "inputs": [ { "name": "mask", "type": "MASK", "link": 6 } ], "outputs": [ { "name": "mask", "type": "MASK", "slot_index": 0, "links": [ 30 ] }, { "name": "mask_inverted", "type": "MASK", "slot_index": 0, "links": [] } ], "properties": { "Node name for S&R": "GrowMaskWithBlur", "cnr_id": "comfyui-kjnodes", "aux_id": "kijai/ComfyUI-KJNodes", "ver": "1.2.5" }, "widgets_values": [ 6, 0.0, true, false, 12.0, 1.0, 1.0, true ], "title": "Person keep mask (grow+feather)" }, { "id": 20, "type": "ImageResizeKJ", "pos": [ 1680, -300 ], "size": [ 300, 190 ], "flags": {}, "order": 20, "mode": 0, "inputs": [ { "name": "image", "type": "IMAGE", "link": 26 }, { "name": "get_image_size", "type": "IMAGE", "link": 27, "shape": 7 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [ 28 ] }, { "name": "width", "type": "INT", "slot_index": 0, "links": [] }, { "name": "height", "type": "INT", "slot_index": 0, "links": [] } ], "properties": { "Node name for S&R": "ImageResizeKJ", "cnr_id": "comfyui-kjnodes", "aux_id": "kijai/ComfyUI-KJNodes", "ver": "1.2.5" }, "widgets_values": [ 1024, 1024, "lanczos", false, 0, "disabled" ], "title": "Resize to original size" }, { "id": 21, "type": "ImageCompositeMasked", "pos": [ 2020, -420 ], "size": [ 300, 170 ], "flags": {}, "order": 21, "mode": 0, "inputs": [ { "name": "destination", "type": "IMAGE", "link": 28 }, { "name": "source", "type": "IMAGE", "link": 29 }, { "name": "mask", "type": "MASK", "link": 30, "shape": 7 } ], "outputs": [ { "name": "IMAGE", "type": "IMAGE", "slot_index": 0, "links": [ 31 ] } ], "properties": { "Node name for S&R": "ImageCompositeMasked", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ 0, 0, false ], "title": "Original person over new background" }, { "id": 22, "type": "SaveImage", "pos": [ 2360, -420 ], "size": [ 400, 460 ], "flags": {}, "order": 22, "mode": 0, "inputs": [ { "name": "images", "type": "IMAGE", "link": 31 } ], "outputs": [], "properties": { "Node name for S&R": "SaveImage", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "flux2-bg-inpaint" ], "title": "Save Image" }, { "id": 23, "type": "MarkdownNote", "pos": [ -40, -940 ], "size": [ 620, 380 ], "flags": {}, "order": 23, "mode": 0, "inputs": [], "outputs": [], "properties": { "Node name for S&R": "MarkdownNote", "cnr_id": "comfy-core", "ver": "0.3.48" }, "widgets_values": [ "## Flux2 BG Inpaint (Klein 9B)\n\n**Masked background regeneration with FLUX.2 Klein 9B via the community noise-mask approach** - Flux.2 has no official inpaint path, so the source image is VAE-encoded, `SetLatentNoiseMask` limits denoising to the background, and `ReferenceLatent` keeps the scene grounded. (needs [ComfyUI-RMBG](https://github.com/1038lab/ComfyUI-RMBG) + [ComfyUI-KJNodes](https://github.com/kijai/ComfyUI-KJNodes))\n\n- **Sampling**: Flux2Scheduler 8 steps (Klein distilled), euler, CFGGuider cfg 1. Width/height feed from the div-16 input resize automatically. `4` steps stays truest to the original layout, `8` adds crisper texture.\n- **Prompt matters**: the default pins the lighting (\"evenly lit, no added shadows, no vignetting\") - without it Klein invents moody side-light and layered wall shadows at denoise 1.\n- **Partial denoise** (*partial denoise* node): `1.0` = full background regen (default). Drop to `0.7-0.85` to keep the original background structure/lighting and only sharpen it.\n- **Background mask**: person mask (SAM3) shrunk 4px + 8px feather, inverted. Person keep mask (`expand 6 / blur 12`) composites the original person back at the end.\n- Input is squashed to the nearest /16 dims for encoding, output resized back to the exact input resolution before the composite.\n- Via API: `--set 4.image=file.png`, `--set 10.text='...'`, `--set 14.steps=4`, `--set 24.denoise=0.8`.\n\n**Models** (all in [aleph65/ComfyUI](https://huggingface.co/aleph65/ComfyUI)): `flux-2-klein-9b`, `qwen_3_8b_fp8mixed`, `flux2-vae`, `sam3.pt`\n" ], "title": "README", "color": "#432", "bgcolor": "#653" } ], "links": [ [ 1, 4, 0, 5, 0, "IMAGE" ], [ 2, 5, 0, 6, 0, "IMAGE" ], [ 3, 3, 0, 6, 1, "VAE" ], [ 4, 4, 0, 7, 0, "IMAGE" ], [ 5, 7, 1, 8, 0, "MASK" ], [ 6, 7, 1, 19, 0, "MASK" ], [ 7, 6, 0, 9, 0, "LATENT" ], [ 8, 8, 1, 9, 1, "MASK" ], [ 9, 2, 0, 10, 0, "CLIP" ], [ 10, 10, 0, 11, 0, "CONDITIONING" ], [ 11, 6, 0, 11, 1, "LATENT" ], [ 12, 10, 0, 12, 0, "CONDITIONING" ], [ 13, 1, 0, 13, 0, "MODEL" ], [ 14, 11, 0, 13, 1, "CONDITIONING" ], [ 15, 12, 0, 13, 2, "CONDITIONING" ], [ 16, 5, 1, 14, 0, "INT" ], [ 17, 5, 2, 14, 1, "INT" ], [ 18, 14, 0, 24, 0, "SIGMAS" ], [ 19, 16, 0, 17, 0, "NOISE" ], [ 20, 13, 0, 17, 1, "GUIDER" ], [ 21, 15, 0, 17, 2, "SAMPLER" ], [ 22, 24, 1, 17, 3, "SIGMAS" ], [ 23, 9, 0, 17, 4, "LATENT" ], [ 24, 17, 0, 18, 0, "LATENT" ], [ 25, 3, 0, 18, 1, "VAE" ], [ 26, 18, 0, 20, 0, "IMAGE" ], [ 27, 4, 0, 20, 1, "IMAGE" ], [ 28, 20, 0, 21, 0, "IMAGE" ], [ 29, 4, 0, 21, 1, "IMAGE" ], [ 30, 19, 0, 21, 2, "MASK" ], [ 31, 21, 0, 22, 0, "IMAGE" ] ], "groups": [], "config": {}, "extra": { "frontendVersion": "1.45.20" }, "version": 0.4 }