ComfyUI / workflows /api /flux2-bg-inpaint.json
aleph65's picture
Add flux2-bg-inpaint API workflow
297f088 verified
Raw
History Blame Contribute Delete
5.71 kB
{
"1": {
"_meta": {
"title": "Load Flux2 Klein"
},
"class_type": "UNETLoader",
"inputs": {
"unet_name": "flux-2-klein-9b.safetensors",
"weight_dtype": "default"
}
},
"10": {
"_meta": {
"title": "Background prompt"
},
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"2",
0
],
"text": "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"
}
},
"11": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"10",
0
],
"latent": [
"6",
0
]
}
},
"12": {
"_meta": {
"title": "Negative (zeroed)"
},
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"10",
0
]
}
},
"13": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1.0,
"model": [
"1",
0
],
"negative": [
"12",
0
],
"positive": [
"11",
0
]
}
},
"14": {
"class_type": "Flux2Scheduler",
"inputs": {
"height": [
"5",
2
],
"steps": 8,
"width": [
"5",
1
]
}
},
"15": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "euler"
}
},
"16": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 156680208700286
}
},
"17": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"13",
0
],
"latent_image": [
"9",
0
],
"noise": [
"16",
0
],
"sampler": [
"15",
0
],
"sigmas": [
"24",
1
]
}
},
"18": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"17",
0
],
"vae": [
"3",
0
]
}
},
"19": {
"_meta": {
"title": "Person keep mask (grow+feather)"
},
"class_type": "GrowMaskWithBlur",
"inputs": {
"blur_radius": 12.0,
"decay_factor": 1.0,
"expand": 6,
"fill_holes": true,
"flip_input": false,
"incremental_expandrate": 0.0,
"lerp_alpha": 1.0,
"mask": [
"7",
1
],
"tapered_corners": true
}
},
"2": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_8b_fp8mixed.safetensors",
"device": "default",
"type": "flux2"
}
},
"20": {
"_meta": {
"title": "Resize to original size"
},
"class_type": "ImageResizeKJ",
"inputs": {
"crop": "disabled",
"divisible_by": 0,
"get_image_size": [
"4",
0
],
"height": 1024,
"image": [
"18",
0
],
"keep_proportion": false,
"upscale_method": "lanczos",
"width": 1024
}
},
"21": {
"_meta": {
"title": "Original person over new background"
},
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"20",
0
],
"mask": [
"19",
0
],
"resize_source": false,
"source": [
"4",
0
],
"x": 0,
"y": 0
}
},
"22": {
"_meta": {
"title": "Save Image"
},
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "flux2-bg-inpaint",
"images": [
"21",
0
]
}
},
"24": {
"_meta": {
"title": "partial denoise"
},
"class_type": "SplitSigmasDenoise",
"inputs": {
"denoise": 1.0,
"sigmas": [
"14",
0
]
}
},
"3": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "flux2-vae.safetensors"
}
},
"4": {
"_meta": {
"title": "Main Image"
},
"class_type": "LoadImage",
"inputs": {
"image": "example.png"
}
},
"5": {
"_meta": {
"title": "Fit to /16"
},
"class_type": "ImageResizeKJ",
"inputs": {
"crop": "disabled",
"divisible_by": 16,
"height": 0,
"image": [
"4",
0
],
"keep_proportion": false,
"upscale_method": "lanczos",
"width": 0
}
},
"6": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"5",
0
],
"vae": [
"3",
0
]
}
},
"7": {
"_meta": {
"title": "Segment PERSON (SAM3)"
},
"class_type": "SAM3Segment",
"inputs": {
"background": "Alpha",
"confidence_threshold": 0.5,
"device": "Auto",
"image": [
"4",
0
],
"invert_output": false,
"mask_blur": 0,
"mask_offset": 0,
"max_segments": 0,
"output_mode": "Merged",
"prompt": "person",
"segment_pick": 0,
"unload_model": false
}
},
"8": {
"_meta": {
"title": "Background mask (inverted)"
},
"class_type": "GrowMaskWithBlur",
"inputs": {
"blur_radius": 8.0,
"decay_factor": 1.0,
"expand": -4,
"fill_holes": true,
"flip_input": false,
"incremental_expandrate": 0.0,
"lerp_alpha": 1.0,
"mask": [
"7",
1
],
"tapered_corners": true
}
},
"9": {
"class_type": "SetLatentNoiseMask",
"inputs": {
"mask": [
"8",
1
],
"samples": [
"6",
0
]
}
}
}