YOLOV3TinyForObjectDetection
ObjectDetectionModelYOLOV3TinyForObjectDetection(config: YOLOV3Config)YOLOv3-Tiny — the 2-scale lightweight YOLOv3 (Redmon & Farhadi, 2018).
A shallow Darknet backbone (six conv + max-pool stages, no residual
connections) feeding two detection scales — stride 32 and stride 16 —
each through yolov3-tiny.cfg's two-convolution head rather than the
full model's five. Boxes, objectness and per-class sigmoids are decoded
exactly as in YOLOV3ForObjectDetection, so the two share their
loss and postprocess.
Parameters
configYOLOV3Configyolo_v3_tiny supplies yolov3-tiny.cfg's table: six
anchors, strides (16, 32), masks ((0, 1, 2), (3, 4, 5)).
The default YOLOV3Config describes the full model's three
scales and is refused with a ValueError.Attributes
configYOLOV3Configbackbone_Darknet53Tinyp5_compressnn.Sequentialconv 512 3x3 expansion.p5_predictnn.Conv2dp5_to_p4_conv_ConvBnLeakyconv 128 1x1 on the stride-32 bottleneck before upsampling.p4_compressnn.Sequentialconv 256 3x3 over the upsampled-and-concatenated
384 channels.p4_predictnn.Conv2dNotes
See Redmon & Farhadi, "YOLOv3: An Incremental Improvement", 2018 (arXiv:1804.02767). Tiny is the variant released alongside the full model for real-time and embedded inference.
Examples
>>> import lucid
>>> from lucid.models.vision.yolo import yolo_v3_tiny
>>> model = yolo_v3_tiny().eval()
>>> x = lucid.randn(1, 3, 416, 416)
>>> out = model(x)
>>> dets = model.postprocess(out, image_sizes=[(416, 416)])
>>> sorted(dets[0])
['boxes', 'labels', 'scores']Used by 1
Constructors
1Instance methods
2forward(x: Tensor, targets: list[dict[str, Tensor]] | None = None)Run YOLOv3.
Parameters
xtargetsReturns
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", on