YOLOV3ForObjectDetection
PretrainedModelYOLOV3ForObjectDetection(config: YOLOV3Config)YOLOv3 multi-scale object detector (Redmon & Farhadi, 2018).
Adds a 53-layer Darknet-53 backbone (residual connections, more capacity than Darknet-19) and an FPN-style multi-scale detection head that predicts on three feature levels — (stride 8), (stride 16), (stride 32) — with three anchors per cell per level (9 anchors total). This multi-scale detection dramatically improves small-object recall over YOLOv2, bringing COCO AP up to 33.0% (paper Table 3). Per-class predictions use independent sigmoids rather than softmax — supporting multi-label classification.
Parameters
configYOLOV3Configyolo_v3 for the full
Darknet-53 model or yolo_v3_tiny for the lightweight
2-scale variant.Attributes
configYOLOV3Configbackbone_Darknet53p5_compress, p5_predictnn.Sequentialp4_compress, p4_predict, p4_to_p3_convnn.Sequentialp3_compress, p3_predict, p5_to_p4_convnn.SequentialNotes
See Redmon & Farhadi, "YOLOv3: An Incremental Improvement", 2018 (arXiv:1804.02767). Per-anchor box decoding reuses the YOLOv2 direct-location parameterisation; the multi-class objective swaps YOLOv2's softmax for per-class binary cross-entropy:
enabling multi-label predictions where a single object can belong to multiple categories (e.g. "Woman" + "Person").
Examples
>>> import lucid
>>> from lucid.models.vision.yolo._v3 import yolo_v3
>>> model = yolo_v3()
>>> x = lucid.randn(1, 3, 416, 416)
>>> out = model(x)
>>> out.logits.shape[0]
1Used by 1
Constructors
1Instance methods
2forward(x: Tensor, targets: list[dict[str, Tensor]] | None = None)Run YOLOv3.
Parameters
Returns
ObjectDetectionOutputObjectDetectionOutput:
logits : (B, total_anchors, C) raw class logits.
pred_boxes: (B, total_anchors, 4) xyxy decoded boxes.
loss : loss scalar when targets provided.
postprocess(output: ObjectDetectionOutput, image_sizes: list[tuple[int, int]])Filter by score, clip boxes, apply per-class NMS.
Parameters
outputObjectDetectionOutputimage_sizeslist[tuple[int, int]]Returns
list[dict[str, Tensor]]Per-image list of dicts with "boxes", "scores", "labels".