🐳YOLO智能裁剪
Find every face/person/object and crop it, automatically
- image
- 裁剪图像
- 遮罩
- 边界框
- 检测信息
- 检测数量
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 ownBBOXEStype检测信息- 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_name | COMBO | 请将YOLO模型放入models/yolo文件夹 | 1 options: 请将YOLO模型放入models/yolo文件夹 |
| confidence | FLOAT | 0.250–1 | — |
| class_filter | STRING | 全部 | 要检测的类别,用逗号分隔(如:人,汽车)或'全部'检测所有 |
| square_size | FLOAT | 10010–200 | 基于检测对象大小的百分比调整 |
| object_margin | FLOAT | 1.51–3 | 在检测对象周围添加的额外边距系数 |
| vertical_offset | FLOAT | 0-50–50 | — |
| horizontal_offset | FLOAT | 0-50–50 | — |
| sort_by | COMBO | 从左到右 | 9 options: 默认, 从左到右, 从右到左, 从上到下, 从下到上, 置信度降序, +3 |
| crop_mode | COMBO | 全部对象 | 3 options: 全部对象, 单个对象, 按类别 |
| object_index | INT | 00–100 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| 裁剪图像 | IMAGE | — |
| 遮罩 | MASK | — |
| 边界框 | BBOXES | — |
| 检测信息 | STRING | — |
| 检测数量 | INT | — |