Nodes/comfy_Pond_Nodes/🐳YOLO智能裁剪
ComfyUI Node

🐳YOLO智能裁剪

Find every face/person/object and crop it, automatically

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳YOLO智能裁剪
  • image
  • 裁剪图像
  • 遮罩
  • 边界框
  • 检测信息
  • 检测数量
model_name请将YOLO模型放入models/yolo文件夹
confidence0.25
class_filter全部
square_size100
object_margin1.5
vertical_offset0
horizontal_offset0
sort_by从左到右
crop_mode全部对象
object_index0

YOLO Smart Crop (🐳YOLO智能裁剪) is the detection half of a detect→crop→refine→paste loop. Feed it an image and a YOLO model, and it finds the objects - faces, people, cars, whatever the model was trained for - then crops each one out with a sensible amount of margin, sorted and filtered however you like. If you've ever hand-cropped forty faces to run them through a face detailer, this is the node that does it for you in one pass.

It's powered by Ultralytics YOLO, the workhorse object detector the KB's masking/detection doc calls the standard for this job in ComfyUI. The model_name dropdown is populated live from whatever .pt (or .onnx/.engine) files sit in ComfyUI/models/yolo/ - drop yolov8n.pt in that folder, restart, and it appears. The model is loaded once and cached per name, so a long batch doesn't re-init the weights every frame. If the folder's empty, the dropdown shows a Chinese hint telling you to put a YOLO model in models/yolo.

The detection knobs are the standard set: confidence (0-1, default 0.25) is the detection threshold, and class_filter lets you keep only specific classes - type 人,汽车 (person, car) or leave it 全部 for everything. Then come the crop-shaping controls, which are the part most YOLO nodes skip: square_size (10-200% of the detected object size) and object_margin (1-3× margin multiplier) expand the box around what was detected, and vertical_offset/horizontal_offset (±50) nudge the final crop. These matter because a raw YOLO bbox hugs the object, and a tight hug is usually not what you want for a detailer pass - you want context around the face.

sort_by gives you nine orderings (left-to-right, top-to-bottom, confidence, area, ascending or descending), and crop_mode picks the strategy: 全部对象 (crop everything), 单个对象 (just the one at object_index), or 按类别 (per-class crops).

The outputs and the loop

This is where it gets genuinely useful:

  • 裁剪图像 - the cropped IMAGE list (one per detection)
  • 遮罩 - a MASK of the detected regions
  • 边界框 - the bounding boxes, in this pack's own BBOXES type
  • 检测信息 - a STRING describing what was found
  • 检测数量 - the INT count of detections

That BBOXES output is the handshake for the loop: wire it (plus the crops) into the pack's YOLO Image Paste node (🐳YOLO图像拼接), and it will paste your processed crops back onto the original at exactly the right spots. That's the canonical ADetailer-style pipeline from the KB's core loop - detect, crop, re-render, paste back - built from Pond's own nodes instead of Impact Pack's SEGS.

Two things worth knowing. First, licensing: Ultralytics is AGPL-3.0, and the KB flags it as the one dependency with real license teeth if you're shipping anything commercial - plus it has a known supply-chain incident behind it, so pin your version. Second, 裁剪图像 is a list output - wire it to something that accepts a list (like the paste node, or a ForEach/batch splitter), not a plain image input.

Install

Part of Pond Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes
pip install -r requirements.txt

Restart after (or Manager → "comfy_Pond_Nodes"). This node needs ultralytics (installed by the requirements) and a model in ComfyUI/models/yolo/ - the README recommends yolov8n.pt or yolov8s.pt from Ultralytics' releases. Pack caveat: console spam if comfyui_HiDream-Sampler is installed alongside.

Category🐳Pond/yolo

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
model_nameCOMBO请将YOLO模型放入models/yolo文件夹1 options: 请将YOLO模型放入models/yolo文件夹
confidenceFLOAT0.250–1
class_filterSTRING全部要检测的类别,用逗号分隔(如:人,汽车)或'全部'检测所有
square_sizeFLOAT10010–200基于检测对象大小的百分比调整
object_marginFLOAT1.51–3在检测对象周围添加的额外边距系数
vertical_offsetFLOAT0-50–50
horizontal_offsetFLOAT0-50–50
sort_byCOMBO从左到右9 options: 默认, 从左到右, 从右到左, 从上到下, 从下到上, 置信度降序, +3
crop_modeCOMBO全部对象3 options: 全部对象, 单个对象, 按类别
object_indexINT00–100

Outputs (5)

NameTypeDescription
裁剪图像IMAGE
遮罩MASK
边界框BBOXES
检测信息STRING
检测数量INT