Multibox Detection
Turn anchor guesses into actual detections — that's non-max suppression
- cls_probs
- offset_preds
- anchors
- detections
CdlMultiboxDetection is the "make up your mind" step of the pack's object detection pipeline. It takes raw model outputs - class probabilities, box offsets, and the anchor boxes generated by CdlMultiboxPrior - and turns them into actual detected boxes, filtered by confidence and thinned out by non-maximum suppression (NMS). If you've ever wondered how a detector goes from "two million overlapping guesses" to "one clean box per object," this node is that algorithm.
The two things it does deserve their own sentences. Non-max suppression is the algorithm that, when dozens of overlapping boxes all claim the same dog, keeps the most confident one and suppresses the rest. Confidence thresholding is the part that throws away boxes that are probably just noise. Both knobs are exposed as inputs, which makes this the node you tune when your detector is either hallucinating boxes (raise the threshold) or missing objects (lower it).
How it works
It's a port of the d2l multibox_detection function. Per image in the batch it: takes the max class probability (ignoring the background class) for each anchor, applies the inverse offset transform to turn the predicted offsets back into real box coordinates relative to the anchors, runs NMS to kill overlapping duplicates above nms_threshold IoU, then drops everything below pos_threshold confidence and marks the rest as background.
Inputs and output
cls_probs- class probabilities, shape[B, num_classes, N]where N is the number of anchors.offset_preds- predicted box offsets, shape[B, N*4].anchors- from CdlMultiboxPrior, shape[1, N, 4].nms_threshold- float, default 0.5. IoU threshold for suppression; higher = fewer boxes killed.pos_threshold- float, default 0.01. Minimum confidence to keep a box; higher = fewer detections.
The single output is detections, a cdlTensor - the surviving boxes with their class and confidence, ready for the pack's visualization nodes or your own inspection.
Installing ComfyDL
It's part of the ComfyDL pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ComfyDL/requirements.txt
Restart ComfyUI. The only extra dependency is matplotlib; torch comes with ComfyUI. ComfyUI Manager users: search "ComfyDL", and if it's missing from the built-in list (the pack isn't on the official registry yet), use Install via Git URL with the repo link.
Common issues
This is the most input-contract-heavy node in the pack, so shape mismatches are the dominant failure: cls_probs, offset_preds, and anchors must all agree on the anchor count N, and cls_probs[1] (the class axis) is assumed to include a background class at index 0 - if your model doesn't output one, the math silently misbehaves. Tuning is where people actually get frustrated: if you see a flood of overlapping boxes, raise nms_threshold; if you see false positives, raise pos_threshold; if objects vanish, lower them. Change one at a time, because they interact. And remember this node only filters - the model that produced cls_probs and offset_preds is upstream of it, and garbage in, fewer-garbage-out.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| cls_probs | TENSOR | — | |
| offset_preds | TENSOR | — | |
| anchors | TENSOR | — | |
| nms_threshold | FLOAT | 0.500–1 | — |
| pos_threshold | FLOAT | 0.0100–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| detections | TENSOR | — |