Nodes/ComfyUI_KimNodes/🍒YOLO_Crop✀YOLO裁切
ComfyUI Node

🍒YOLO_Crop✀YOLO裁切

Detect a subject, cut it out as a clean square — if you bring the model

By wjl0313·Created 2 years ago·Updated 12 months ago· 54
🍒YOLO_Crop✀YOLO裁切
  • image
  • IMAGE
  • DATA
yolo_model
confidence0.50
square_size100
vertical_offset0
horizontal_offset0

YOLO_Crop is the auto-crop node from the KimNodes pack: run a YOLO detector over an image, find the subject, and hand you a square crop around it - plus the bounding box data so you can paste it back where it came from. The intended loop, per the pack's own README, is exactly that: "cut out the parts detected by YOLO and paste them back onto the original picture."

In practice this is a lighter cousin of what Impact Pack's FaceDetailer machinery does - detect, crop, process, paste back - but YOLO_Crop doesn't run a new sampling pass; it just gives you the crop. Where that's useful: making consistent square thumbnails of faces from a batch, cutting a subject loose for compositing, or pre-processing before feeding a region to a detailer. It only ever crops the first detected box into the IMAGE output, so think of it as "crop the primary subject," not "crop everything."

How it works

You feed it an image and a yolo_model picked from a dropdown. The dropdown is populated from .pt files it finds in ComfyUI/models/yolo/ - a path relative to your ComfyUI root, not inside the custom node folder. It runs Ultralytics YOLO predict at your confidence threshold, keeps detections of class 0 (person/face), and builds a square crop around the largest edge of the detection, scaled by square_size (which is a percentage - 100 means "the detection size," not 100 pixels). vertical_offset and horizontal_offset shift the crop as percentages of the square, useful for re-centering on a face.

Outputs: IMAGE (the cropped square) and DATA - a dict with the original pixels plus normalized bboxes (xmin/ymin/xmax/ymax), which is exactly the format Crop_Paste expects to put it back.

The inputs that matter

  • yolo_model - must exist in ComfyUI/models/yolo/ first. This is the gotcha that bites everyone.
  • confidence - default 0.5; raise it if you're getting junk crops.
  • square_size - 100 = natural, lower crops tighter, higher adds margin.

Installation and the big gotchas

Pack install is standard (Manager → "ComfyUI_KimNodes", or clone into custom_nodes). But two things will trip you before this node ever runs:

  1. No YOLO model ships with the pack. The README never mentions downloading weights. You must drop a .pt (e.g. yolov8n-face.pt or the common face_yolov9c.pt) into ComfyUI/models/yolo/ yourself. Empty folder = empty dropdown.
  2. ultralytics is not in the pack's requirements.txt (only pixeloe is). Worse, the pack's __init__.py imports every module eagerly, so a missing ultralytics doesn't just break this node - the entire pack fails to load. If the pack never appears after install:
pip install ultralytics opencv-python

One more thing worth knowing: Ultralytics is AGPL-licensed, and its Python package had a well-documented supply-chain compromise (a cryptominer) in December 2024 that reached ComfyUI users through exactly this kind of YOLO node. Pin a known-good ultralytics version rather than blindly upgrading, and don't be surprised that it's the package most security-minded users watch.

Troubleshooting

  • No crop returned, original image comes back - that's the "no detections" path. Raise confidence down, or your model isn't picking up the subject class (it only keeps class 0).
  • Empty yolo_model dropdown - check ComfyUI/models/yolo/ actually has a .pt file and restart.
  • Crops are off-center - play with the two offsets; faces sit above the bbox center more often than not.
Category🍒 Kim-Nodes/✂ Crop | 裁剪工具

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
yolo_modelCOMBO0 options:
confidenceFLOAT0.500.1–1
square_sizeFLOAT10010–200
vertical_offsetFLOAT0-512–512
horizontal_offsetFLOAT0-512–512

Outputs (2)

NameTypeDescription
IMAGEIMAGE
DATADATA