🍒Crop_Paste✀裁切粘贴
Crop_Paste puts the thing you cropped back where it came from
- image
- crop_images
- data
- IMAGE
The classic ComfyUI trick for fixing a bad face or hand is detect → crop → re-generate → paste back. YOLO_Crop gives you the crop; Crop_Paste closes the loop by putting your processed crops back onto the original image at exactly the right spot. The pack's own README pairs the two by name: "cut out the parts detected by YOLO and paste them back onto the original picture."
It's the paste-back half of that pipeline, and it's designed to be driven by the DATA output of YOLO_Crop, which contains normalized bounding boxes plus the source pixels. If you've used Impact Pack's FaceDetailer loop, the shape of this is familiar - this one just doesn't run the sampling pass; it's pure compositing.
How it works
You give it image (the original), crop_images (the batch of processed crops, in the same order the detector found them), data (the YOLO_Crop DATA dict), and feather_amount. For each crop it reads the corresponding normalized bbox from data["bboxes"], converts it back to pixel coordinates against the original image size, resizes the crop to fill that box, and pastes it in place with the alpha preserved.
Now, the honest note: feather_amount is in the inputs, and the code even defaults it to 0.2, but it isn't actually applied. The paste is a hard rectangular paste - no feathered mask, no gradient blend. If you were expecting soft edges, you'll get hard ones, and the setting will appear to do nothing. That's a real limitation of the current code, worth knowing before you lean on it for seamless compositing.
The inputs that matter
image- the untouched original.crop_images- your re-generated or processed crops as a batch, in detection order.data- the DATA dict from YOLO_Crop (it readsdata["bboxes"], expecting normalizedxmin/ymin/xmax/ymaxper box).feather_amount- currently cosmetic; see above.
Output: a single IMAGE, the original with crops pasted in.
Installation
Standard KimNodes pack install - Manager → search "ComfyUI_KimNodes" → Install → Restart, or git clone https://github.com/wjl0313/ComfyUI_KimNodes into custom_nodes. Pure PIL/torch, no extra dependencies.
Common issues
- Crops paste in the wrong place - the bbox dict must have normalized coordinates (
xmin/ymin/xmax/ymaxin 0–1). If your data source uses pixel coordinates, the paste will be wildly off. YOLO_Crop's DATA output is in the right format. - Crop count mismatch - the node pastes
min(batch_size, len(bboxes))pairs; if you filtered crops between YOLO_Crop and here, the indices misalign and things paste over the wrong subjects. - Hard edges that won't blend - that's the missing feather implementation. If you need soft seams, run the pasted result through a blur-based masking approach or pick a node that actually feathers.
- The whole pack missing from your menu - the standard pack gotcha:
__init__.pyimports everything at load, and a missingultralytics(the YOLO nodes need it) blocks the entire pack.pip install ultralytics opencv-pythonand restart.
If you're building a face-detail loop, this node plus YOLO_Crop plus a KSampler in the middle is a compact, understandable stand-in for the heavyweight detailer packs - just remember it's hard-edged.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| crop_images | IMAGE | — | |
| data | DATA | — | |
| feather_amount | FLOAT | 0.200–0.5 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |