YOLOV1ForObjectDetection
PretrainedModelYOLOV1ForObjectDetection(config: YOLOV1Config)YOLOv1 single-shot object detector (Redmon et al., CVPR 2016).
The original "You Only Look Once" detector — recasts object detection as a single regression problem. An AlexNet-derived Darknet backbone processes the whole image, then an adaptive-average-pool + two FC layers produce an tensor: for each of grid cells, candidate boxes and class probabilities. A box is responsible for an object iff the object's centre falls inside that cell. No anchors, no region proposals — a single forward pass yields all detections at 45 fps on a Titan X.
Parameters
configYOLOV1Configyolo_v1 for the full
Darknet backbone or yolo_v1_tiny for the lightweight
Tiny variant; both default to PASCAL VOC's S = 7,
B = 2, C = 20.Attributes
configYOLOV1Configdarknetnn.Sequentialconfig.tiny).fc1, fc2nn.LinearNotes
See Redmon et al., "You Only Look Once: Unified, Real-Time Object Detection", CVPR 2016 (arXiv:1506.02640). The defining multi-part loss is
with , to balance localisation vs. background regression. The square-root parameterisation on width / height down-weights errors in large boxes.
Examples
>>> import lucid
>>> from lucid.models.vision.yolo._v1 import yolo_v1
>>> model = yolo_v1()
>>> x = lucid.randn(1, 3, 448, 448) # YOLOv1 trained at 448
>>> out = model(x)
>>> out.logits.shape[-1] >= 20
TrueUsed by 1
Constructors
1Instance methods
2forward(x: Tensor, targets: list[dict[str, Tensor]] | None = None, image_size: tuple[int, int] = (448, 448))Run YOLOv1 forward pass.
Parameters
"boxes": (M_i, 4) xyxy boxes normalised to [0, 1].
- "labels": (M_i,) integer class indices.image_sizetuple[int, int]= (448, 448)Returns
ObjectDetectionOutputclass:~lucid.models._output.ObjectDetectionOutput with:
postprocess(output: ObjectDetectionOutput, image_size: tuple[int, int] = (448, 448))Per-class NMS on raw predictions.
Parameters
outputObjectDetectionOutputforward.image_sizetuple[int, int]= (448, 448)Returns
list[dict[str, Tensor]]List of per-image result dicts with "boxes", "scores",