diff --git a/deployments/ai-stack/openwebui-tools/smart_image_gen.py b/deployments/ai-stack/openwebui-tools/smart_image_gen.py index 51a37b7..b65110a 100644 --- a/deployments/ai-stack/openwebui-tools/smart_image_gen.py +++ b/deployments/ai-stack/openwebui-tools/smart_image_gen.py @@ -1,7 +1,7 @@ """ title: Smart Image Generator & Editor (ComfyUI) author: ai-stack -version: 0.7.5 +version: 0.7.6 description: Generate or edit images via ComfyUI with automatic SDXL checkpoint routing. Two methods — generate_image (txt2img) and edit_image (img2img on the user's most recently attached image). The @@ -303,6 +303,13 @@ def _build_inpaint(positive: str, negative: str, settings: dict, "the dog's collar"), then SetLatentNoiseMask + KSampler repaint only that region. Everything outside the mask stays pixel-perfect. + The raw SAM mask is run through GrowMask with tapered_corners + before it reaches the sampler. Without that, the mask edge is + pixel-binary and KSampler repaints right up to a hard boundary — + SDXL has no surrounding-pixel context inside the mask to blend + with, so the inpainted region looks pasted-on with visible seams. + expand=12px + taper gives a soft transition that blends naturally. + First inpaint downloads ~3 GB of SAM/GroundingDINO weights into /opt/comfyui/models/{sams,grounding-dino}/ — subsequent runs reuse them. @@ -329,7 +336,7 @@ def _build_inpaint(positive: str, negative: str, settings: dict, "11": {"class_type": "VAEEncode", "inputs": {"pixels": ["12", 0], "vae": ["4", 2]}}, "12": {"class_type": "LoadImage", "inputs": {"image": image_filename}}, "13": {"class_type": "SetLatentNoiseMask", - "inputs": {"samples": ["11", 0], "mask": ["16", 1]}}, + "inputs": {"samples": ["11", 0], "mask": ["17", 0]}}, "14": {"class_type": "SAMModelLoader (segment anything)", "inputs": {"model_name": "sam_hq_vit_h (2.57GB)"}}, "15": {"class_type": "GroundingDinoModelLoader (segment anything)", @@ -342,6 +349,12 @@ def _build_inpaint(positive: str, negative: str, settings: dict, "prompt": mask_text, "threshold": 0.3, }}, + "17": {"class_type": "GrowMask", + "inputs": { + "mask": ["16", 1], + "expand": 12, + "tapered_corners": True, + }}, }