Playing with YOLO v1 Object Detection on Google Colab
Object detection is a central problem in computer vision, with applications ranging from face detection and autonomous driving to medical image analysis and surveillance systems. The goal is to determine where in an image objects are located, and what those objects are.
Early object detection methods like Viola-Jones (2001) used sliding window classifiers to exhaustively search for objects at every position and scale. Later, region proposal methods like R-CNN (2014) would first generate potential bounding boxes using a region proposal network or traditional computer vision techniques, then classify those boxes.
While these multi-stage pipelines achieved good results, they were often slow and complex. In 2015, a new approach called YOLO ("You Only Look Once") took the object detection world by storm. YOLO reframed object detection as a single regression problem, straight from image pixels to bounding box coordinates and class probabilities.

*Figure 1: YOLO model architecture. A single convolutional network predicts bounding boxes and class probabilities directly from image pixels in one evaluation. Source: Redmon et al., 2015* [^1]
The key ideas behind YOLO are:
-
Unified architecture: A single convolutional neural network predicts bounding boxes and class probabilities directly from image pixels in one evaluation. This means the entire model can be trained end-to-end directly on detection performance.
-
Grid-based prediction: YOLO divides the input image into an S×S grid (e.g. 7×7). Each grid cell is responsible for predicting B bounding boxes and C class probabilities. By making predictions at a coarse spatial resolution, YOLO is able to run very efficiently.
-
Bounding box priors: Instead of predicting raw bounding box coordinates, YOLO predicts offsets relative to pre-defined default bounding boxes, known as "priors" or "anchors". This makes the model more stable and easier to learn.
To explain the YOLO v1 architecture in more detail, let‘s visualize the model and walk through it layer-by-layer:
from tensorflow.keras.utils import plot_model
plot_model(yolo_model, to_file=‘yolo_v1_architecture.png‘, show_shapes=True, show_layer_names=True, expand_nested=True, dpi=64)

The YOLO v1 architecture consists of 24 convolutional layers followed by 2 fully connected layers. The convolutional layers are used for feature extraction, while the fully connected layers predict the output probabilities and coordinates.
Here are the main components:
-
Image input (448 × 448 × 3): The input image is resized to a fixed size of 448×448. Using a larger input size allows detecting smaller objects.
-
Convolutional layers (7 × 7 × 64 to 14 × 14 × 1024): A series of convolutional layers of varying filter sizes and strides extract features from the image at multiple scales. Padding is used to preserve spatial dimensions. Leaky ReLU activations and max pooling are used throughout.
-
Fully connected layers (1024 and 4096 units): Two fully connected layers process the flattened feature maps to make predictions. A linear activation is used for the final layer.
-
Output tensor (7 × 7 × 30): The final 7×7×30 tensor encodes the bounding box and class predictions for each spatial location. For each of the 7×7 grid cells, there are 30 values:
- 2 bounding boxes (each with 5 values: center coordinates, dimensions, and confidence)
- 20 class probabilities
So in total, YOLO v1 predicts (7×7×2 =) 98 bounding boxes per image. The predicted boxes are sorted by confidence and non-max suppression is applied to remove duplicates.
YOLO v1 Results
So how well does YOLO v1 actually perform? Here are some key results on the PASCAL VOC dataset, one of the main benchmarks at the time:
| Model | Train | mAP (VOC 2007 test) | FPS (448×448) |
|---|---|---|---|
| YOLO v1 | VOC 2007+12 | 63.4 | 45 |
| Fast YOLO v1 | VOC 2007+12 | 52.7 | 155 |
Table 1: YOLO v1 accuracy and speed on PASCAL VOC. mAP is mean average precision, FPS is frames per second on a Titan X GPU.
On the VOC 2007 test set, YOLO v1 achieves 63.4% mAP (mean average precision) at 45 FPS, while the Fast YOLO variant gets 52.7% mAP at an impressive 155 FPS. For comparison, the previous state-of-the-art Faster R-CNN model got 73.2% mAP at 7 FPS [^2], so YOLO trades off some accuracy for large gains in speed.
Here‘s a more detailed breakdown of YOLO v1‘s performance on VOC 2007:
| Class | AP | Class | AP |
|---|---|---|---|
| aeroplane | 0.7147 | diningtable | 0.6583 |
| bicycle | 0.7742 | dog | 0.7859 |
| bird | 0.6748 | horse | 0.8024 |
| boat | 0.5309 | motorbike | 0.7184 |
| bottle | 0.3888 | person | 0.6554 |
| bus | 0.7197 | pottedplant | 0.2897 |
| car | 0.7541 | sheep | 0.6089 |
| cat | 0.8141 | sofa | 0.5733 |
| chair | 0.4214 | train | 0.7783 |
| cow | 0.6494 | tvmonitor | 0.6554 |
Table 2: Per-class average precision (AP) scores for YOLO v1 on PASCAL VOC 2007 test set. Source: Redmon et al., 2015 [^1]
YOLO performs best on animals like cats and dogs, vehicles like bicycles and cars, and large objects like trains and buses. It performs worse on small objects like bottles and potted plants.
To further test YOLO‘s speed-accuracy tradeoff, the authors compare the full and fast YOLO models on VOC 2007 while varying the input size:
| Model | Input resolution | mAP | FPS |
|---|---|---|---|
| YOLO | 448×448 | 0.634 | 45 |
| Fast YOLO | 448×448 | 0.527 | 155 |
| YOLO | 288×288 | 0.589 | 98 |
| Fast YOLO | 288×288 | 0.330 | 411 |
| YOLO | 224×224 | 0.546 | 156 |
| Fast YOLO | 224×224 | 0.218 | 730 |
Table 3: YOLO v1 speed-accuracy tradeoff results with varying input resolutions. Source: Redmon et al., 2015 [^1]
The full YOLO model is more accurate but slower, while Fast YOLO is less accurate but extremely fast (up to 730 FPS at 224×224 resolution). Interestingly, at 224×224 the full YOLO model actually runs faster than at 288×288, likely due to better GPU utilization.
Applications and Limitations
So what are YOLO v1‘s strengths and potential use cases? Some key advantages are:
- Speed: YOLO is extremely fast, enabling real-time detection on video streams or implementation on embedded devices.
- Simplicity: YOLO is a simple, unified model that is easy to implement, train and optimize compared to multi-stage pipelines.
- Generalization: By seeing the entire image when making predictions, YOLO implicitly learns contextual information and generalizes well to new domains.
These make YOLO a good fit for applications like:
- Real-time detection on robots, drones or mobile phones
- Detecting objects in video streams for surveillance or monitoring
- Counting objects in images for stock assessment or crowd analysis
- Tracking objects across video frames
However, YOLO v1 also has some significant limitations:
- Fixed grid: By dividing the image into a fixed 7×7 grid, YOLO has trouble detecting very small or unusually shaped objects.
- Coarse features: The 224×224 to 448×448 input size provides limited resolution for localizing smaller objects.
- Struggles with crowds: YOLO imposes strong spatial constraints so it struggles with images containing large crowds of objects.
- Training difficulties: The large number of predicted boxes and direct location prediction lead to unstable, harder to optimize training.
To address these issues, future versions of YOLO introduced ideas like multi-scale training, fine-grained features, anchor boxes, and objectness prediction. We‘ll cover those in later blog posts – stay tuned!
Conclusion and References
In this deep dive on YOLO v1, we explored the core ideas behind this influential object detection model, including its unified architecture, grid-based prediction and bounding box priors. Through code examples and visualizations, we saw how to implement YOLO v1 in Google Colab and run it on our own images.
Detailed speed and accuracy benchmarks showed how YOLO compares to other leading detection methods, and how its full and fast variants trade off accuracy for speed. While not the most accurate, YOLO‘s simplicity and efficiency make it well-suited for real-time and embedded applications.
To learn more about YOLO v1 and object detection, check out these key references:
[^1]: Redmon, J., Divvala, S., Girshick, R. and Farhadi, A., 2016. You only look once: Unified, real-time object detection. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 779-788). https://arxiv.org/abs/1506.02640 [^2]: Ren, S., He, K., Girshick, R. and Sun, J., 2015. Faster r-cnn: Towards real-time object detection with region proposal networks. Advances in neural information processing systems, 28. https://arxiv.org/abs/1506.01497 [^3]: Redmon, J. and Farhadi, A., 2017. YOLO9000: better, faster, stronger. In Proceedings of the IEEE conference on computer vision and pattern recognition (pp. 7263-7271). https://arxiv.org/abs/1612.08242 [^4]: Redmon, J. and Farhadi, A., 2018. Yolov3: An incremental improvement. https://arxiv.org/abs/1804.02767