Nodes/ComfyUI-Inpaint-CropStitch-NB2/Smart Object Isolate Crop
ComfyUI Node

Smart Object Isolate Crop

Smart Object Isolate Crop — show the editor the garment and nothing else

By amortegui84·Created 5 months ago·Updated 3 months ago· 3
Smart Object Isolate Crop
  • image
  • mask
  • stitcher
  • isolated_image
  • isolated_mask
  • isolated_mask_image
  • preview_image
  • info
resize_modeupscale_to_target_if_smaller
target_width1024
target_height1024
mask_expand_percent0.0
alpha_feather_percent1.50
target_size_modemax_for_aspect_ratio
target_aspect_ratiomask_bbox
outside_fillgray
downscale_algorithmbilinear
upscale_algorithmbicubic
device_modegpu (much faster)
depad_florencetrue
region_info
edge_guard_percent3.00
crop_padding_percent8.0
visible_context_percent10.0

Smart Mask Crop sends the editor a crop with the mask drawn on it - but the rest of the crop is still visible, so GPT Image can "helpfully" rebuild the whole scene. Smart Object Isolate Crop takes the opposite approach: it hides every pixel outside the semantic mask, hands the model an RGBA isolated object on a blank background, and only that object is up for editing.

It's purpose-built for garment and product detail passes - the pack's recommended use is texture/detail enhancement on a garment that already exists, not replacement. If you want to swap the garment or change the silhouette, this is the wrong tool; if you want to enhance the fabric weave, seams, and stitching on the bra or pants someone is already wearing, this is exactly the tool.

How it works

You feed it image and a mask (usually from Florence-2 with region_type = object, or from the SAM 3 segmenter with a garment prompt). It crops to the object's bounding box, blanks everything outside the mask, and outputs an RGBA isolated_image plus matching mask. The editor only ever sees the object. Then the stitcher pastes the enhanced object back into the source, so the body and background stay bit-identical.

Inputs worth knowing

  • edge_guard_percent (default 3) - forces the outer crop border to remain uneditable. This is a subtle killer feature: it discourages editors from completing garments that are cut off by the crop or the source frame. Without it, GPT Image will happily grow a sleeve that was cropped mid-arm.
  • outside_fill (black/white/gray/transparent_rgb_black) - the RGB color written outside the object in case a downstream model ignores alpha. gray is the default and a fine middle ground.
  • alpha_feather_percent (default 1.5) - softens the isolated object's edge and the final paste mask.
  • target_size_mode / target_aspect_ratio - default to max_for_aspect_ratio with mask_bbox, which gives you the largest valid edit size at the object's own shape. Good default.
  • crop_padding_percent (default 8) and visible_context_percent (default 10) - padding expands the crop so original skin/background survives nearby; visible_context_percent shows a thin ring of original pixels around the object while keeping the edit mask limited to the garment. That ring matters for color coherence.
  • mask_expand_percent - keep near 0; the tooltip says it plainly: "avoid body context."

The flow

Florence object "bra"  -> Smart Object Isolate Crop -> GPT Image 2 Edit \
Florence object "pants" -> Smart Object Isolate Crop -> GPT Image 2 Edit  -> Smart Mask Multi Stitch -> final image

Wire isolated_image → editor image_1, isolated_mask_imagemask_image, inforegion_info, and set the editor's size_mode = auto_from_region. For separate top/bottom passes, run two selectors and two edits, then combine with Smart Mask Multi Stitch - the pack ships this exact setup as 06_florence_garment_detail_gpt_image2_multistitch.json and a Seedream 4.5 version as 07_....

Prompting matters here. The README's suggested prompt is worth cribbing: enhance fabric texture/seams/weave only on the visible garment, preserve silhouette, cut-off edges, position, scale, and blank background, and do not add body, skin, or mannequin.

Install

Search comfyui-inpaint-cropstitch-nb2 in Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2

Restart. The crop is local; the selector (Florence/SAM via FAL) and the editor need FAL_KEY.

Categoryinpaint/masked

Inputs (18)

NameTypeDefaultDescription
imageIMAGE
maskMASK
resize_modeCOMBOupscale_to_target_if_smaller3 options: keep_local_size, upscale_to_target_if_smaller, resize_to_target
target_widthINT102464–16384
target_heightINT102464–16384
mask_expand_percentFLOAT0.00–30Small expansion for edit coverage. Keep near 0 to avoid body context.
alpha_feather_percentFLOAT1.500–20Softens the isolated object edge and final paste mask.
target_size_modeCOMBOmax_for_aspect_ratio2 options: manual_width_height, max_for_aspect_ratio
target_aspect_ratioCOMBOmask_bbox11 options: mask_bbox, input_image, 1:1, 16:9, 9:16, 4:5, +5
outside_fillCOMBOgrayRGB color written outside the object in case a downstream model ignores alpha.
downscale_algorithmCOMBObilinear6 options: nearest, bilinear, bicubic, lanczos, box, hamming
upscale_algorithmCOMBObicubic6 options: nearest, bilinear, bicubic, lanczos, box, hamming
device_modeCOMBOgpu (much faster)2 options: gpu (much faster), cpu (compatible)
depad_florenceBOOLEANtrueKeep True when the mask comes from Florence-2.
region_infooptSTRING
edge_guard_percentoptFLOAT3.000–15Forces the outer crop border to remain uneditable. This discourages image editors from completing garments that are cut off by the crop or source frame.
crop_padding_percentoptFLOAT8.00–60Expands the crop around the garment so nearby original skin/background can be preserved.
visible_context_percentoptFLOAT10.00–80Shows a small ring of original pixels around the garment to the editor. The edit mask remains limited to the garment.

Outputs (6)

NameTypeDescription
stitcherSTITCHER
isolated_imageIMAGE
isolated_maskMASK
isolated_mask_imageIMAGE
preview_imageIMAGE
infoSTRING