Nodes/ComfyUI-I2I-slim/Cut (Inpaint Segments)
ComfyUI Node

Cut (Inpaint Segments)

Give a 64-pixel face the whole 1024 budget

By GeraldWie·Created about a year ago·Updated about a year ago· 0
Cut (Inpaint Segments)
  • image
  • mask
  • mask_mapping_optional
  • cut image
  • cut mask
  • region
force_resize_width1024
force_resize_height1024
kind
padding3
constraints
constraint_x64
constraint_y64
min_width0
min_height0
batch_behavior

A face occupying 64 pixels of a 1024×1024 frame gets 64 pixels worth of model attention, and it comes out mush. The fix that every serious inpainter converges on is brutally simple: crop the tiny region, regenerate it at full resolution, paste it back. Cut (Inpaint Segments) is the crop half of that trick, and it's the node that makes the whole thing feel automatic.

What it does

You feed it an image and a mask, and it does three things per mask region: finds the bounding box of each blob, crops the image to that box (with a little padding of context around it), and resizes the crop to a working size - force_resize_width / force_resize_height, both defaulting to 1024. What comes out is a region that occupies the model's full generation budget instead of a corner of it.

The crop sizing is where the defaults stop being enough, which is why the inputs look intimidating:

  • constraints and constraint_x / constraint_y - multiple_of snaps each crop to a multiple of your model's native resolution (64 for SDXL, 8 or 16 for Flux). keep_ratio and keep_ratio_divisible hold aspect instead.
  • min_width / min_height - a floor so a 12-pixel spec of dust doesn't get blown up into a 1024 blur.
  • batch_behavior - match_size forces every crop to the same pixel size (good for a consistent batch), match_ratio matches aspect ratios instead.
  • kind - whether the output is mask, RGB, or RGBA. Leave RGB unless you need the alpha.

The outputs and the wiring

It returns three things: cut image (your crops, ready for the sampler), cut mask (the per-crop mask), and region (the geometry that lets Paste put everything back). The intended chain, which the pack ships as a basic workflow, is:

LoadImage → Mask Ops → Cut (Inpaint Segments) → KSampler → VAE Decode → Paste (Combine and Paste) → Preview

One gotcha the schema hides: this node's mask input is an IMAGE, not a MASK. You can't drag a MASK wire straight into it - feed it the mask_image output from Mask Ops, or whatever image form of the mask you have.

Installing it

It lives in ComfyUI-I2I-slim, GeraldWie's lean fork of ManglerFTW's ComfyI2I. ComfyUI Manager:

Manager → Install Custom Nodes → search "ComfyUI-I2I-slim" → Install → Restart

or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/GeraldWie/ComfyUI-I2I-slim
cd ComfyUI-I2I-slim
pip install -r requirements.txt

No model downloads. Be aware the requirements file lists tensorflow and scikit-image that the code never imports - the real runtime deps are numpy, torch, torchvision, opencv and PIL, so don't feel obliged to install the whole list.

Common issues

  • Crops come out the wrong shape or resolution - that's constraints doing its thing. If you want plain crops, set it to ignore.
  • Fixing small details with no context - the inpainting playbook says give detail fixes 32-64px of padding. This node's padding is in pixels and defaults small, so bump it when the regenerated region is missing the surrounding context it needs to blend.
  • Cut produces something useless with an empty mask - an all-black mask has no bounding box to crop. Make sure your mask has actual white regions.
  • Batch size mismatch downstream - if Paste complains about a missing entry for a mask index, you generated fewer images than there are regions; check your sampler's batch count.

The name says "segments" and that's the point: one mask, many regions, each edited at full resolution and stitched back. For the crop-and-stitch inpainting pattern, this is the crop.

CategoryI2I-slim

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
maskIMAGE
force_resize_widthINT10240–1048576
force_resize_heightINT10240–1048576
kindCOMBO3 options: mask, RGB, RGBA
paddingINT30–1048576
constraintsCOMBO4 options: keep_ratio, keep_ratio_divisible, multiple_of, ignore
constraint_xINT642–1048576
constraint_yINT642–1048576
min_widthINT00–1048576
min_heightINT00–1048576
batch_behaviorCOMBO2 options: match_ratio, match_size
mask_mapping_optionaloptMASK_MAPPING

Outputs (3)

NameTypeDescription
cut imageIMAGE
cut maskIMAGE
regionIMAGE