Yolo v1 bounding boxes during training step
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
In exploring the foundations of real-time object detection, the YOLO (You Only Look Once) algorithm stands as a pivotal advancement. YOLO v1, introduced by Joseph Redmon et al., is renowned for its efficiency and speed, particularly due to its unique method of handling bounding boxes during the training step. Here, we break down the technicalities involved with YOLO v1 bounding boxes.
YOLO v1 Bounding Boxes
YOLO v1 treats object detection as a single regression problem, directly predicting bounding boxes and class probabilities from full images in one evaluation. Unlike previous designs that repurpose classifiers or localizers to perform detection, YOLO v1 maintains a different approach by harnessing a single convolutional neural network (CNN) that simultaneously predicts multiple bounding boxes and their likelihoods.
Grid Division
The YOLO algorithm divides the input image into an grid of cells. Each grid cell is responsible for predicting bounding boxes if the center of a ground-truth object lies within it. Typical grid sizes are , where each cell predicts a fixed number of boxes.
Bounding Box Prediction
For each grid cell in the YOLO v1 architecture:
• Bounding Boxes: Each cell predicts bounding boxes, with each box defined by five elements: . • : These are the coordinates corresponding to the center of the bounding box within the grid cell. The values are normalized between 0 and 1 relative to the grid cell. • : Width and height are also predictions of the bounding box, normalized concerning the image dimensions. • : This stands for the confidence score, which represents the predicted confidence that the box contains an object and the accuracy of the bounding box itself. This is calculated as:
• Class Predictions: Each grid cell has a set of class probabilities conditioned on the cell containing an object.
`Loss` Function
YOLO v1 uses a custom loss function that combines aspects of both localization and classification, focused on:
• Localization `Loss` (bbox coordinates): Measures errors in bounding box predictions using sum-squared error, typically giving higher weight to coordinate accuracy. • Confidence Loss: Two parts evaluate this: • One part evaluates the squared error of the confidence score for boxes that contain objects. • The other evaluates confidence for boxes without objects, promoting low confidence predictions where no object exists. • Classification Loss: Evaluated only for grid cells containing an object.
The overall loss can be expressed as:
where is 1 if an object appears in cell and bounding box is responsible for the prediction, while is 1 when that box is not responsible for an object.
Technical Summary
| Feature | Description |
| Grid Size | Typically |
| Bounding Box Prediction | for each of boxes per grid cell |
Loss Function Components | Localization, confidence, classification |
| Normalization | Coordinates and dimensions are relative to grid cell/image dimensions |
Confidence Score | Combines probability of object presence and IOU with ground truth |
| Class Prediction | Conditioned on object having presence in cell |
Model Training and Optimization
Overlapping Detections
YOLO v1 does not focus on refining bounding boxes post-prediction. Instead, it trains an end-to-end model to predict bounding boxes directly. Non-Maximum Suppression (NMS) is typically used during post-processing to handle overlapping detections.
Limitations
YOLO v1 assumes only one object is present per grid cell, which can lead to performance bottlenecks with small objects. Bounding box aspect ratios are also restricted, as only a fixed number per grid cell are predicted.
Conclusion
YOLO v1 represents a significant step in object detection by integrating detection into a single neural network function. Its unique handling of bounding boxes during training and application of a multi-component loss function ensured efficient, real-time predictions that laid the groundwork for future YOLO iterations.
Related reading
- 3d model construction using multiple images from multiple points kinect
- A guide to convert_imageset.cpp
- Active Shape Models matching model points to target points
- Adding AdditiveGaussianNoise to a single image - AssertionError Expected boolean as argument for 'return_batch
- You must feed a value for placeholder tensor 'Placeholder' with dtype float
- Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least steps_per_epoch
- Your favourite algorithm and the lesson it taught you
- YouTube URL algorithm?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.