# SSD

## Introduction

[SSD: Single Shot MultiBox Detector](https://arxiv.org/abs/1512.02325) (by W\.Liu, C. Szegedy et al.,2016), object detector scoring over 74% mAP at 59 FPS on [PascalVOC](http://host.robots.ox.ac.uk/pascal/VOC/) and [COCO](http://cocodataset.org/#home).

* **Single Shot:** this means that the tasks of object localization and classification *\_are done in a \_single* *forward pass* of the network
* **MultiBox:** this is the name of a technique for bounding box regression developed by Szegedy et al. (we will briefly cover it shortly)
* **Detector:** The network is an object detector that also classifies those detected objects

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-3e279b10cc8e179cb838699c0897e9c262c420ea%2Fimage%20\(204\).png?alt=media)

## Single Shot MultiBox Detector <a href="#id-7a47" id="id-7a47"></a>

### Architecture

Based on VGG-16. No FC layers but added a set of *auxiliary* convolutional layers (from *conv6* onwards). This can extract features at multiple scales and progressively decrease the size of the input to each subsequent layer.

![A comparison between two single shot detection models: SSD and YOLO \[5\]. Our SSD model adds several feature layers to the end of a base network, which predict the offsets to default boxes of different scales and aspect ratios and their associated confidences. SSD with a 300 × 300 input size significantly outperforms its 448 × 448 YOLO counterpart in accuracy on VOC2007 test while also improving the speed.](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-bdc16d29057dd2b9917a408693c014d942aad4a5%2Fimage%20\(203\).png?alt=media)

#### Baseline: VGG architecture

![VGG architecture (input is 224x224x3)](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-5bfeeffb93c82eb3474efe5d0b8b21759a74f4ec%2Fimage%20\(205\).png?alt=media)

#### MultiBox

The bounding box regression technique of SSD is inspired by Szegedy’s work on [MultiBox](https://arxiv.org/abs/1412.1441). MultiBox starts with the **priors as predictions** and attempt to regress closer to the ground truth bounding boxes. At the end, MultiBox only retains the top K predictions that have minimised both location (*LOC*) and confidence (*CONF*) losses.

Multibox: It is for Bounding Box Proposal of fast *class-agnostic* bounding box coordinate proposals.

> Class-agnostic means bounding box of object without classfication

Multibox contains 11 priors per feature map cell (8x8, 6x6, 4x4, 3x3, 2x2) and only one on the 1x1 feature map, resulting in a total of 1420 priors per image

> 11\*(8\*8)+11\*(6\*6)+...+11\*(2\*2)=1419 + 1(1\*1)=1420

![Architecture of multi-scale convolutional prediction of the location and confidences of multibox](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-004a9977934c72eb0477ec97b25989c9bdb0786b%2Fimage%20\(210\).png?alt=media)

MultiBox’s loss function also combined two critical components:

***multibox\_loss = confidence\_loss + alpha \* location\_loss***

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-4fbea34552acc21a49e1fd3ce9e5c78c3bda0037%2Fimage%20\(208\).png?alt=media)

* **Confidence Loss**: this measures how confident the network is of the *objectness* of the computed bounding box. Categorical [cross-entropy](https://rdipietro.github.io/friendly-intro-to-cross-entropy-loss/#cross-entropy) is used to compute this loss.
* **Location Loss:** this measures how *far away* the network’s predicted bounding boxes are from the ground truth ones from the training set. [L2-Norm](https://rorasa.wordpress.com/2012/05/13/l0-norm-l1-norm-l2-norm-l-infinity-norm/) is used here.

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-f715515d4d110e9efb978f51648a2401455b3e21%2Fimage%20\(209\).png?alt=media)

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-7da72c47bc1295dd0380cad3f65d619fcf8ec7b4%2Fimage%20\(207\).png?alt=media)

### **Results** <a href="#ce75" id="ce75"></a>

#### **Default Bounding Boxes**

The SSD paper has around 6 bounding boxes per feature map cell.

#### **Pascal VOC 2007**

![](https://3883264845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MR8tEAjhiC8uN1kHR2J%2Fuploads%2Fgit-blob-e8564056a7cb4e1c0e93afa9d5c4fbc2902c8248%2Fimage%20\(211\).png?alt=media)

## Additional Notes On SSD <a href="#id-52ce" id="id-52ce"></a>

The SSD paper makes the following additional observations:

* more default boxes results in more accurate detection, although there is an impact on speed
* having MultiBox on multiple layers results in better detection as well, due to the detector running on features at multiple resolutions
* 80% of the time is spent on the base VGG-16 network: this means that with a faster and equally accurate network SSD’s performance could be even better
* SSD confuses objects with similar categories (e.g. animals). This is probably because locations are shared for multiple classes
* SSD-500 (the highest resolution variant using 512x512 input images) achieves best mAP on Pascal VOC2007 at 76.8%, but at the expense of speed, where its frame rate drops to 22 fps. SSD-300 is thus a much better trade-off with 74.3 mAP at 59 fps.
* SSD produces worse performance on smaller objects, as they may not appear across all feature maps. Increasing the input image resolution alleviates this problem but does not completely address it
