Object Detection at the Edge: A Deep Dive into YOLO and MobileNet SSD

Object detection is a fundamental task in computer vision with wide-ranging applications from autonomous driving to video surveillance to cashierless checkout. The goal is to not only classify the objects present in an image, but also localize them with bounding boxes. While early approaches like Viola-Jones and HOG+SVM were limited to a single object class, the advent of deep learning has enabled detection of thousands of object categories in real-world scenes.

In this article, we‘ll take a detailed look at two popular single-stage object detection architectures: YOLO (You Only Look Once) and MobileNet SSD (Single Shot MultiBox Detector). Single-stage detectors have emerged as the leading paradigm for real-time object detection, offering a favorable speed-accuracy trade-off compared to two-stage detectors like Faster R-CNN. We‘ll dive deep into the key innovations that enable these models to achieve state-of-the-art performance, compare their strengths and weaknesses, and discuss practical considerations for deployment on resource-constrained edge devices.

YOLO: You Only Look Once

YOLO is a family of single-stage object detectors that frame detection as a regression problem. The key idea is to divide the input image into a grid of cells and have each cell directly predict a set of bounding boxes and class probabilities. This allows the model to reason globally about the full image and all the objects in it, unlike sliding window or region proposal-based approaches.

YOLO Architecture

The YOLO architecture consists of two main components: a feature extractor backbone and a detection head. The backbone is typically a deep convolutional neural network (CNN) like ResNet, DarkNet, or EfficientNet that generates a set of feature maps at multiple scales. The detection head then takes these feature maps as input and applies a series of convolutional and fully-connected layers to predict the bounding boxes and class probabilities for each grid cell.

One of the key innovations in YOLO is the use of anchor boxes. Rather than directly predicting bounding box coordinates, YOLO predicts offsets relative to a set of predefined default bounding boxes called anchors. The anchors are chosen to match the size and aspect ratio distribution of the objects in the dataset, which makes the learning problem easier and improves convergence. During training, each anchor is assigned to a ground-truth bounding box based on the highest IoU overlap. The model is then optimized to minimize a multi-part loss function that accounts for localization error, objectness confidence, and classification error.

Another important feature of YOLO is the ability to predict at multiple scales. This is achieved by applying the detection head to feature maps of different resolutions, allowing the model to detect objects of various sizes. For example, YOLOv3 makes predictions at three scales using features from different layers of the backbone network.

YOLO Performance

Since its introduction in 2015, YOLO has undergone several iterations that have significantly improved its speed and accuracy. Table 1 shows the performance of different YOLO versions on the COCO object detection benchmark.

Model Input Size [email protected] FPS (GPU)
YOLOv1 448×448 63.4 45
YOLOv2 416×416 76.8 67
YOLOv3-320 320×320 51.5 45
YOLOv3-416 416×416 55.3 35
YOLOv3-608 608×608 57.9 20
YOLOv4 416×416 62.8 54
YOLOv4 608×608 65.7 33
YOLOv5s 640×640 56.8 140
YOLOv5l 640×640 64.2 60
YOLOv7 640×640 69.7 161
YOLOv8n 640×640 50.0 619

Table 1. Performance of YOLO models on COCO test-dev. [email protected] is mean Average Precision at 0.5 IoU threshold. FPS is measured on a single NVIDIA V100 GPU.

As we can see, the accuracy of YOLO has improved significantly over time, from 63.4 [email protected] for YOLOv1 to 69.7 [email protected] for YOLOv7. At the same time, the speed has also increased dramatically, with YOLOv7 running at over 160 FPS on a high-end GPU. The latest YOLOv8 pushes the envelope even further, achieving over 600 FPS while maintaining competitive accuracy.

Some of the key innovations that have enabled these improvements include:

  • Stronger backbone networks (e.g. CSPDarknet53 in YOLOv4)
  • Improved loss functions (e.g. Complete IoU loss in YOLOv8)
  • Bag of freebies (BoF) like data augmentation, loss regularization
  • Bag of specials (BoS) like SPP, PAN, SAM
  • Neural architecture search (NAS) for optimal model design

Despite its impressive performance, YOLO does have some limitations. It struggles with small objects and dense scenes due to its coarse-grained grid structure. It also has more localization error compared to two-stage detectors, especially for objects with high aspect ratios. Some of these issues have been addressed in more recent versions through techniques like fine-grained features, anchor-free detection, and deformable convolutions.

MobileNet SSD: Efficient Detection for Mobile

MobileNet SSD is a single-stage object detector designed specifically for fast inference on mobile and embedded devices. It combines the SSD detection framework with the MobileNet family of efficient CNN architectures to achieve a good balance between speed, accuracy, and model size.

SSD Architecture

SSD is a single-stage detection framework that eliminates the need for a separate region proposal step. Instead, it directly predicts a set of default bounding boxes with different scales and aspect ratios at each location in a set of feature maps. The default boxes are similar to the anchor boxes used in YOLO, but are applied to feature maps at multiple scales.

During training, each default box is matched to a ground-truth object based on the IoU overlap. The model is then optimized to predict the offset of each default box and the probability of each object class being present. SSD uses a weighted sum of localization loss and confidence loss, with hard negative mining to balance positive and negative examples.

One of the key innovations in SSD is the use of feature maps at multiple scales for prediction. This allows the model to detect objects of different sizes without requiring multiple input scales or feature pyramids. SSD typically uses 6 feature maps with resolutions ranging from 38×38 to 1×1, with each map responsible for a different scale of objects.

MobileNet Architecture

MobileNet is a family of efficient CNN architectures designed for mobile and embedded vision applications. The key building block is the depthwise separable convolution, which factorizes a standard convolution into a depthwise convolution (spatial filtering) and a pointwise convolution (channel mixing). This significantly reduces the number of parameters and computational cost compared to standard convolutions.

MobileNet introduces two hyperparameters to further control the model size and latency: width multiplier α and resolution multiplier ρ. The width multiplier thins the network uniformly at each layer by reducing the number of channels. The resolution multiplier scales the input image resolution, allowing a trade-off between accuracy and latency. Table 2 shows the performance of MobileNet with different multiplier values on ImageNet classification.

Model Width Mult. Res Mult. Params MAdds Top-1 Acc.
MobileNet_v1 1.0 1.0 4.2M 569M 70.6
MobileNet_v1 0.75 1.0 2.6M 325M 68.4
MobileNet_v1 0.5 1.0 1.3M 149M 63.7
MobileNet_v1 0.25 1.0 0.5M 41M 50.6
MobileNet_v1 1.0 0.75 4.2M 316M 67.2
MobileNet_v1 1.0 0.5 4.2M 97M 57.2

Table 2. Performance of MobileNet v1 on ImageNet. MAdds is the number of multiply-adds.

More recent versions of MobileNet (v2 and v3) introduce further optimizations like inverted residuals, linear bottlenecks, and squeeze-excitation blocks to improve the accuracy-latency trade-off.

MobileNet SSD Performance

MobileNet SSD combines the SSD framework with MobileNet as the backbone feature extractor. This allows it to achieve real-time object detection on mobile and embedded devices with limited computational resources.

Table 3 compares the performance of MobileNet SSD with other efficient object detectors on the COCO dataset. MobileNet SSD achieves competitive accuracy with a much smaller model size and lower latency compared to YOLO models. This makes it well-suited for applications like mobile augmented reality, drone-based sensing, and edge AI.

Model Input Size [email protected] Params MAdds Latency (ms)
SSD300 300×300 23.2 36.1M 35.2B 12.1
SSDLite 320×320 22.2 4.3M 0.8B 5.8
MobileNet SSD 300×300 22.2 5.8M 1.2B 6.8
MobileNetV2 SSD 320×320 22.1 4.3M 0.8B 6.1
MobileNetV3 SSD 320×320 22.0 2.9M 0.6B 5.5
YOLOv3-tiny 416×416 33.1 8.8M 5.6B 15.8
YOLOv4-tiny 416×416 40.2 6.1M 6.9B 8.8

Table 3. Performance of efficient object detectors on COCO test-dev. Latency is measured on a Pixel 4 phone CPU.

Like YOLO, MobileNet SSD also has some limitations. Its accuracy is generally lower than larger models, especially for small objects and complex scenes. The use of depthwise convolutions can also lead to artifacts and reduced feature representation power. Some recent work has proposed techniques like feature fusion, attention mechanisms, and NAS to address these issues and further improve the accuracy-efficiency trade-off.

Challenges and Future Directions

Despite the impressive progress in object detection over the past decade, there are still many open challenges and opportunities for future research. Some of the key challenges include:

  1. Small object detection: Detecting small objects is difficult due to their low resolution and lack of distinctive features. Current approaches include using high-resolution input, feature pyramids, and context modeling. Promising directions include super-resolution, GAN-based augmentation, and weakly-supervised learning from image-level labels.

  2. Domain adaptation: Object detectors often suffer from domain shift when applied to new scenarios with different object appearance, viewpoints, and backgrounds. Unsupervised domain adaptation techniques like adversarial learning and self-training have shown promising results. Other directions include few-shot learning, meta-learning, and test-time adaptation.

  3. 3D object detection: Detecting objects in 3D space is important for applications like autonomous driving and robotics. Current approaches include voxel-based, point-based, and graph-based methods. Key challenges include efficiency, occlusion reasoning, and sensor fusion. Promising directions include sparse convolutions, transformer architectures, and unsupervised learning from large-scale 3D data.

  4. Efficient deployment: Deploying object detectors on resource-constrained devices requires careful optimization of model architecture, quantization, pruning, and hardware acceleration. Current approaches include platform-aware NAS, dynamic inference, and specialized chips like TPUs and NPUs. Key challenges include balancing accuracy and efficiency, supporting diverse hardware, and enabling on-device learning.

Looking ahead, we can expect object detection to become even more accurate, robust, and efficient. Techniques like unsupervised learning, active learning, and lifelong learning will enable detectors to learn from large-scale unlabeled data and adapt to new domains and tasks over time. Integration with other perception modalities like depth, thermal, and radar will enable more reliable detection in challenging conditions. And advances in edge AI hardware and software will make it possible to deploy sophisticated detectors on a wide range of devices for intelligent sensing and interaction.

Conclusion

YOLO and MobileNet SSD are two prominent examples of single-stage object detectors that have pushed the boundaries of accuracy and efficiency. YOLO is known for its strong performance and real-time speed on high-end GPUs, while MobileNet SSD is optimized for fast inference on mobile and embedded devices. Both detectors have undergone significant evolution and improvement over the years, with techniques like anchor boxes, feature pyramids, and efficient backbones.

When choosing an object detector for a specific application, it‘s important to consider factors like accuracy, speed, model size, and hardware constraints. YOLO is a good choice for applications that require high accuracy and can afford larger models and GPUs, while MobileNet SSD is preferred for applications that prioritize efficiency and need to run on mobile or embedded devices.

Regardless of the specific architecture, the field of object detection is rapidly advancing and holds great promise for enabling intelligent perception in a wide range of domains. By understanding the key ideas and trade-offs behind state-of-the-art detectors, practitioners can make informed decisions and apply them effectively to their own problems. As an AI/ML expert, staying up-to-date with the latest developments and best practices is crucial for pushing the boundaries of what‘s possible and unlocking the full potential of object detection.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Similar Posts