detection
YOLOv8 detection in one dumb node
- image
- IMAGE
- JSON
YOLOv8 doesn't get much hype in ComfyUI, because by the time you're building graphs you usually want the mask more than the box. But sometimes the box is the whole point - you want to know what is in your image, or route the result somewhere based on it - and that's exactly the job this node was built for. Feed it an image and a model, and it hands back the image with bounding boxes drawn on it plus a small JSON of what it found. No API key, no cloud call, no pip-install drama. It just runs YOLOv8 locally and plots the results.
This is the simpler half of a two-node pack by zcfrank1st. Both nodes load their models from the same models/yolov8/ folder, so they share one setup; the sibling Yolov8Segmentation node swaps the boxes for an actual mask. The pack is dead simple on purpose - its README is a three-liner and its entire codebase is one file. That's not a criticism, it's the point: if you want ComfyUI-RMBG's hundred-node sprawl, this isn't it.
How it works
Under the hood the node loads a .pt file from ComfyUI/models/yolov8/, runs it over your image with Ultralytics' YOLO inference, and calls results[0].plot() - the same helper that draws boxes and labels onto the frame when you use YOLO from the command line. The plotted image comes out as the first output; the second output is a JSON object holding the class IDs it detected.
One thing to know: that JSON is thinner than it looks. The code only records the first detected class per result, so if you're dreaming of a clean list of every person and car to drive a switch node, this isn't that. It's "did the model find anything, and what was the top hit." Use it for eyeballing or coarse routing, not a full detection manifest.
The inputs that matter
- image - any
IMAGEtensor. Note it expects a single image; the code squeezes the batch dimension, so a batched tensor will throw. - model_name - a dropdown populated from whatever
.ptfiles you've dropped intomodels/yolov8/. Any YOLOv8 weights work, so you're not stuck with the COCO defaults; there's a whole cottage industry of fine-tuned YOLO models (faces, hands, anatomy) that drop right in.
Outputs: the annotated IMAGE, and the JSON with the detected class.
Installing it
The usual two ways. ComfyUI Manager - search for "ComfyUI Yolov8" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/zcfrank1st/Comfyui-Yolov8
Then restart ComfyUI, and download a model into ComfyUI/models/yolov8/ (e.g. yolov8n.pt from the Ultralytics releases page).
Here's the trap that gets everyone: the pack has no requirements.txt, so nothing auto-installs its runtime. Manager will happily clone it and load it, and then the node errors out because ultralytics isn't in your Python environment. You have to install that yourself - into the same Python ComfyUI uses:
# on the standard portable Windows install
ComfyUI\python_embeded\python.exe -m pip install ultralytics
# or if ComfyUI runs in a venv
pip install ultralytics
Where people get burned
- Empty detections crash it. If the model finds nothing, the JSON output does
classes.tolist()[0]on an empty list and raisesIndexError. If your image has no matching objects, expect a red node. - It's slow because it reloads the model every run. There's no caching - each execution re-reads the weights from disk, adding a second or two. Fine for one-off checks, annoying in a loop.
- Licensing. Ultralytics YOLO is AGPL-3.0, which reaches the detection weights and runtime, not just this pack's few lines of code. If you're shipping something commercial, get that answered before you build on it.
If what you actually want is a cutout or a mask to feed inpainting, skip this node and go straight to Yolov8Segmentation - or reach for SAM or BiRefNet when you need soft edges. This one is for the moment you just need to know what's in the frame.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_name | COMBO | 0 options: |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| JSON | JSON | — |