Skip to content

Single Shot MultiBox Detector

SSD: Single Shot MultiBox Detector.

Abstract

We present a method for detecting objects in images using a single deep neural network. Our approach, named SSD, discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location. At prediction time, the network generates scores for the presence of each object category in each default box and produces adjustments to the box to better match the object shape. Additionally, the network combines predictions from multiple feature maps with different resolutions to naturally handle objects of various sizes. Our SSD model is simple relative to methods that require object proposals because it completely eliminates proposal generation and subsequent pixel or feature resampling stage and encapsulates all computation in a single network. This makes SSD easy to train and straightforward to integrate into systems that require a detection component. Experimental results on the PASCAL VOC, MS COCO, and ILSVRC datasets confirm that SSD has comparable accuracy to methods that utilize an additional object proposal step and is much faster, while providing a unified framework for both training and inference. Compared to other single stage methods, SSD has much better accuracy, even with a smaller input image size. For 300×300 input, SSD achieves 72.1% mAP on VOC2007 test at 58 FPS on a Nvidia Titan X and for 500×500 input, SSD achieves 75.1% mAP, outperforming a comparable state of the art Faster R-CNN model. Code is available at this https URL.

Python2 -> Python3 migration

  1. caffe/model_libs.py및 ssd관련 python 파일에 포함에 모든 xrange함수를 range로 변경한다.
  2. caffe/model_libs.pyassert len > 0를 제거.
  3. caffe/model_libs.pyVGGNetBody함수에 있는 floating 으로 계산된 pad변수를 모두 integer로 전환한다. (e.g. pad = int(pad))

Performance Test

  • Ubuntu 16.04 LTS
  • weiliu89-caffe-ssd master
  • Intel Xeon(R) CPU E5-2698 v4 @ 2.20GHz * 40
  • Tesla V100-DGXS-16GB/PCIe/SSE2
  • OS-Type 16bit
  • Memory 251.8GiB
  • Disk: 7.6TB

SSD 300x300 결과

  • 1회당 약 0.017ms ~ 0.025ms 소요.
  • 1개 GPU만 사용.
  • 1Processor 당 GPU Memory 1374MiB 필요
  • 1Processor 당 100Iteration, 총 11Processor 사용 (총 1100장) -> 평균 32.450ms
  • 온도: 43도 -> 46도 증가
  • 전력: 68W -> 100~200W 증가
  • GPU 점유율: 60~70%

참고로 1Processor 당 100Iteration, 1개만 사용했을 경우 약 26.733~27.467ms 소요.

Category

Troubleshooting

Protobuf TypeError

Python3에서 ssd를 사용할 경우 아래와 같은 에러가 발생될 수 있다.

Traceback (most recent call last):
  File "asset/models/ssd/ssd_pascal.py", line 460, in <module>
    print(net.to_proto(), file=f)
  File "/Users/your/Project/cyclops/script/pycaffe/caffe/net_spec.py", line 211, in to_proto
    top._to_proto(layers, names, autonames)
  File "/Users/your/Project/cyclops/script/pycaffe/caffe/net_spec.py", line 101, in _to_proto
    return self.fn._to_proto(layers, names, autonames)
  File "/Users/your/Project/cyclops/script/pycaffe/caffe/net_spec.py", line 164, in _to_proto
    _param_names[self.type_name] + '_param'), k, v)
  File "/Users/your/Project/cyclops/script/pycaffe/caffe/net_spec.py", line 75, in assign_proto
    getattr(proto, name).extend(val)
  File "/Users/your/.pyenv/versions/3.5.3/envs/__your_pyclops_opy_3.5.3__/lib/python3.5/site-packages/google/protobuf/internal/containers.py", line 275, in extend
    new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
  File "/Users/your/.pyenv/versions/3.5.3/envs/__your_pyclops_opy_3.5.3__/lib/python3.5/site-packages/google/protobuf/internal/containers.py", line 275, in <listcomp>
    new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
  File "/Users/your/.pyenv/versions/3.5.3/envs/__your_pyclops_opy_3.5.3__/lib/python3.5/site-packages/google/protobuf/internal/type_checkers.py", line 133, in CheckValue
    raise TypeError(message)
TypeError: 1.0 has type <class 'float'>, but expected one of: (<class 'int'>,)

이는 Protobuf의 Type이 정상적이지 않아 발생되는 현상이다. 보통 Python2에서 Python3으로 넘어갈 때, 나눗셈 결과가 int에서 float으로 변경되며 발생될 가능성이 크다.

디버깅을 위해 아래와 같이 출력코드를 입력한다.

  • caffe/net_spec.py
# ...
def assign_proto(proto, name, val):
    # ...
            print("* Debugging name: " + name) ## 디버깅을 위해 추가한다.
            getattr(proto, name).extend(val)
    # ...
# ...
  • caffe/net_spec.py
# ...
class Function(object):
    # ...
    def _to_proto(self, layers, names, autonames):
        # ...
        layer.name = self._get_name(names, autonames)
        print("layer.name: " + layer.name) ## 디버깅을 위해 추가한다.
        # ...
# ...

이렇게 하면 어떤 레이어의 어떤 속성이 문제인지 알 수 있다.

Documentation

SSD - Single Shot MultiBox Detector
https://arxiv.org/abs/1512.02325
1512.02325v4.pdf
1512.02325v5.pdf
SSD - Single Shot MultiBox Detector - eccv2016 slide
http://www.cs.unc.edu/%7Ewliu/papers/ssd_eccv2016_slide.pdf
Ssd_eccv2016_slide.pdf
weiliu89-caffe-ssd master
https://github.com/weiliu89/caffe/tree/ssd
Caffe-ssd-77c1c51.zip
Caffe-ssd-efdc164.zip
A PyTorch Implementation of Single Shot MultiBox Detector
https://github.com/amdegroot/ssd.pytorch
Single Shot MultiBox Detector Implementation in Pytorch
MobileNetV1, MobileNetV2, VGG based SSD/SSD-lite implementation in Pytorch 1.0 / Pytorch 0.4. Out-of-box support for retraining on Open Images dataset. ONNX and Caffe2 support. Experiment Ideas like CoordConv.
https://github.com/qfgaohao/pytorch-ssd
Understand Single Shot MultiBox Detector (SSD) and Implement It in Pytorch

See also

Favorite site

References


  1. DeepLAB_library_4027_-SSD-_Single_Shot_MultiBox_Detector.pdf 

  2. Sogangori_-Single_Shot_MultiBox_Detector-_Review.pdf