ComfyUI / workflows /api /qwen-bg-enhance.json
aleph65's picture
Add qwen-bg-enhance API workflow
fe6f836 verified
Raw
History Blame Contribute Delete
11 kB
{
"1": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_edit_2511_bf16.safetensors",
"weight_dtype": "default"
}
},
"13": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"53:6",
0
],
"shift": 3.1
}
},
"14": {
"class_type": "CFGNorm",
"inputs": {
"model": [
"13",
0
],
"pre_cfg": false,
"strength": 1
}
},
"15": {
"_meta": {
"title": "upscale_input_to_max_size"
},
"class_type": "PrimitiveBoolean",
"inputs": {
"value": true
}
},
"16": {
"_meta": {
"title": "downscale_input_to_max_size"
},
"class_type": "PrimitiveBoolean",
"inputs": {
"value": false
}
},
"20": {
"_meta": {
"title": "Main Image"
},
"class_type": "LoadImage",
"inputs": {
"image": "733427737_18059858666742129_6215894921112236726_n.jpg"
}
},
"21": {
"_meta": {
"title": "Input max size (main)"
},
"class_type": "PrimitiveInt",
"inputs": {
"value": 2048
}
},
"27": {
"_meta": {
"title": "Main image config"
},
"class_type": "QwenEditConfigPreparer",
"inputs": {
"image": [
"20",
0
],
"ref_crop": "pad",
"ref_longest_edge": [
"54:5",
0
],
"ref_main_image": true,
"ref_upscale": "lanczos",
"to_ref": true,
"to_vl": true,
"vl_crop": "center",
"vl_resize": true,
"vl_target_size": 384,
"vl_upscale": "bicubic"
}
},
"3": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b.safetensors",
"device": "default",
"type": "qwen_image"
}
},
"4": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_vae.safetensors"
}
},
"40": {
"_meta": {
"title": "Qwen Edit Encode (prompt here)"
},
"class_type": "TextEncodeQwenImageEditPlusCustom_lrzjason",
"inputs": {
"clip": [
"3",
0
],
"configs": [
"27",
0
],
"instruction": "",
"prompt": "Keep the person exactly as they are, unchanged. Regenerate the background into a sharp, photorealistic, high-detail version of the same scene: crisp focus, clean fine texture, natural depth and perspective. Remove all blur, bokeh, compression artifacts, noise and distortion from the background. Match the lighting, color temperature and white balance to the subject. High quality, ultra sharp details, 4k.",
"return_full_refs_cond": true,
"vae": [
"4",
0
]
}
},
"41": {
"class_type": "QwenEditOutputExtractor",
"inputs": {
"custom_output": [
"40",
2
]
}
},
"42": {
"_meta": {
"title": "Negative (zeroed)"
},
"class_type": "ConditioningZeroOut",
"inputs": {
"conditioning": [
"40",
0
]
}
},
"43": {
"class_type": "KSampler",
"inputs": {
"cfg": [
"53:14",
0
],
"denoise": 1,
"latent_image": [
"40",
1
],
"model": [
"14",
0
],
"negative": [
"42",
0
],
"positive": [
"40",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 440984114065874,
"steps": [
"53:11",
0
]
}
},
"44": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"43",
0
],
"vae": [
"4",
0
]
}
},
"45": {
"_meta": {
"title": "Remove padding"
},
"class_type": "CropWithPadInfo",
"inputs": {
"image": [
"44",
0
],
"pad_info": [
"41",
0
]
}
},
"5": {
"_meta": {
"title": "Sampling mode: 1=4-step / 2=8-step / 3=quality"
},
"class_type": "PrimitiveInt",
"inputs": {
"value": 1
}
},
"50": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "qwen-bg-enhance",
"images": [
"63",
0
]
}
},
"52": {
"_meta": {
"title": "User LoRAs"
},
"class_type": "Power Lora Loader (rgthree)",
"inputs": {
"lora_1": {
"lora": "Qwen_LoRA_Skin_Fix_v2.safetensors",
"on": false,
"strength": 1,
"strengthTwo": null
},
"lora_2": {
"lora": "Qwen_LoRA_Amateur_Photo_v1.safetensors",
"on": false,
"strength": 1,
"strengthTwo": null
},
"model": [
"1",
0
]
}
},
"53:1": {
"_meta": {
"title": "LoRA: Lightning 4 steps"
},
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
"model": [
"52",
0
],
"strength_model": 1
}
},
"53:10": {
"_meta": {
"title": "Steps switch 4/8"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"53:7",
0
],
"on_true": [
"53:8",
0
],
"switch": [
"53:3",
2
]
}
},
"53:11": {
"_meta": {
"title": "Steps switch quality"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"53:10",
0
],
"on_true": [
"53:9",
0
],
"switch": [
"53:4",
2
]
}
},
"53:12": {
"_meta": {
"title": "CFG (lightning)"
},
"class_type": "PrimitiveFloat",
"inputs": {
"value": 1.0
}
},
"53:13": {
"_meta": {
"title": "CFG (quality)"
},
"class_type": "PrimitiveFloat",
"inputs": {
"value": 3.0
}
},
"53:14": {
"_meta": {
"title": "CFG switch"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"53:12",
0
],
"on_true": [
"53:13",
0
],
"switch": [
"53:4",
2
]
}
},
"53:2": {
"_meta": {
"title": "LoRA: Lightning 8 steps"
},
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Qwen-Image-Edit-2511-Lightning-8steps-V1.0-bf16.safetensors",
"model": [
"52",
0
],
"strength_model": 1
}
},
"53:3": {
"_meta": {
"title": "is 8-step (mode == 2)"
},
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a == 2",
"values.a": [
"5",
0
]
}
},
"53:4": {
"_meta": {
"title": "is quality (mode == 3)"
},
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a == 3",
"values.a": [
"5",
0
]
}
},
"53:5": {
"_meta": {
"title": "Model switch 4/8"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"53:1",
0
],
"on_true": [
"53:2",
0
],
"switch": [
"53:3",
2
]
}
},
"53:6": {
"_meta": {
"title": "Model switch quality"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"53:5",
0
],
"on_true": [
"52",
0
],
"switch": [
"53:4",
2
]
}
},
"53:7": {
"_meta": {
"title": "Steps (4-step)"
},
"class_type": "PrimitiveInt",
"inputs": {
"value": 4
}
},
"53:8": {
"_meta": {
"title": "Steps (8-step)"
},
"class_type": "PrimitiveInt",
"inputs": {
"value": 8
}
},
"53:9": {
"_meta": {
"title": "Steps (quality)"
},
"class_type": "PrimitiveInt",
"inputs": {
"value": 12
}
},
"54:1": {
"_meta": {
"title": "native edge"
},
"class_type": "MathExpression|pysssss",
"inputs": {
"a": [
"20",
0
],
"expression": "max(a.width, a.height)"
}
},
"54:2": {
"_meta": {
"title": "upscaled edge"
},
"class_type": "MathExpression|pysssss",
"inputs": {
"a": [
"20",
0
],
"c": [
"21",
0
],
"expression": "max(a.width, a.height, c)"
}
},
"54:3": {
"_meta": {
"title": "apply upscale"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"54:1",
0
],
"on_true": [
"54:2",
0
],
"switch": [
"15",
0
]
}
},
"54:4": {
"_meta": {
"title": "downscaled edge"
},
"class_type": "MathExpression|pysssss",
"inputs": {
"a": [
"54:3",
0
],
"c": [
"21",
0
],
"expression": "min(a, c)"
}
},
"54:5": {
"_meta": {
"title": "apply downscale"
},
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"54:3",
0
],
"on_true": [
"54:4",
0
],
"switch": [
"16",
0
]
}
},
"60": {
"_meta": {
"title": "Segment PERSON (SAM3)"
},
"class_type": "SAM3Segment",
"inputs": {
"background": "Alpha",
"confidence_threshold": 0.5,
"device": "Auto",
"image": [
"20",
0
],
"invert_output": false,
"mask_blur": 0,
"mask_offset": 0,
"max_segments": 0,
"output_mode": "Merged",
"prompt": "person",
"segment_pick": 0,
"unload_model": false
}
},
"61": {
"_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": [
"60",
1
],
"tapered_corners": true
}
},
"62": {
"_meta": {
"title": "Resize to original size"
},
"class_type": "ImageResizeKJ",
"inputs": {
"crop": "disabled",
"divisible_by": 0,
"get_image_size": [
"20",
0
],
"height": 1024,
"image": [
"45",
0
],
"keep_proportion": false,
"upscale_method": "lanczos",
"width": 1024
}
},
"63": {
"_meta": {
"title": "Original person over new background"
},
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"62",
0
],
"mask": [
"61",
0
],
"resize_source": false,
"source": [
"20",
0
],
"x": 0,
"y": 0
}
}
}