← Back to Projects
Computer VisionPlatform: Personal Project

YOLO Object Detection

YOLO Object Detection

1. Context & Objective

An introduction to real-time object detection using a pre-trained YOLOv5 model. Explored how YOLO performs single-shot detection to identify and localize multiple objects in images and video streams.

2. Methodology

1. Loaded a pre-trained YOLOv5s model from Ultralytics. 2. Ran inference on test images and video frames. 3. Parsed bounding boxes, confidence scores, and class labels. 4. Rendered detections with OpenCV for visualization.
In [1]:
import torch, cv2

model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)

results = model('test_image.jpg')
results.print()
results.show()

cap = cv2.VideoCapture('video.mp4')
while cap.isOpened():
    ret, frame = cap.read()
    if not ret: break
    results = model(frame)
    cv2.imshow('YOLO', results.render()[0])

3. Final Learnings

YOLO's single-pass architecture makes real-time detection feasible even on a laptop CPU. Confidence thresholds are critical — too low floods with false positives, too high drops valid detections.

Dataset details

Language

Python

Size

Libraries Used

YOLOv5OpenCVPyTorch