• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 4 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SSD: Single Shot MultiBox Detector pytorch implementation focusing on simplicity

SSD: Single Shot MultiBox Detector

Introduction

Here is my pytorch implementation of 2 models: SSD-Resnet50 and SSDLite-MobilenetV2. These models are based on original model (SSD-VGG16) described in the paper SSD: Single Shot MultiBox Detector. This implementation supports mixed precision training.


An example of SSD Resnet50's output.

Motivation

Why this implementation exists while there are many ssd implementations already ?

I believe that many of you when seeing this implementation have this question in your mind. Indeed there are already many implementations for SSD and its variants in Pytorch. However most of them are either:

  • over-complicated
  • modularized
  • many improvements added
  • not evaluated/visualized

The above-mentioned points make learner hard to understand how original ssd looks like. Hence, I re-implement this well-known model, focusing on simplicity. I believe this implementation is suitable for ML/DL users from different levels, especially beginners. In compared to model described in the paper, there are some minor changes (e.g. backbone), but other parts follow paper strictly.

Datasets

Dataset Classes #Train images #Validation images
COCO2017 80 118k 5k
  • COCO: Download the coco images and annotations from coco website. Make sure to put the files as the following structure (The root folder names coco):
    coco
    β”œβ”€β”€ annotations
    β”‚   β”œβ”€β”€ instances_train2017.json
    β”‚   └── instances_val2017.json
    │── train2017
    └── val2017 
    

Docker

For being convenient, I provide Dockerfile which could be used for running training as well as test phases

Assume that docker image's name is ssd. You already created an empty folder name trained_models for storing trained weights. Then you clone this repository and cd into it.

Build:

docker build --network=host -t ssd .

Run:

docker run --rm -it -v path/to/your/coco:/coco -v path/to/trained_models:/trained_models --ipc=host --network=host ssd

How to use my code

Assume that at this step, you either already installed necessary libraries or you are inside docker container

Now, with my code, you can:

  • Train your model by running python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE train.py --model [ssd|ssdlite] --batch-size [int] [--amp]. You could stop or resume your training process whenever you want. For example, if you stop your training process after 10 epochs, the next time you run the training script, your training process will continue from epoch 10. mAP evaluation, by default, will be run at the end of each epoch. Note: By specifying --amp flag, your model will be trained with mixed precision (FP32 and FP16) instead of full precision (FP32) by default. Mixed precision training reduces gpu usage and therefore allows you train your model with bigger batch size while sacrificing negligible accuracy. More infomation could be found at apex and pytorch.
  • Test your model for COCO dataset by running python test_dataset.py --pretrained_model path/to/trained_model
  • Test your model for image by running python test_image.py --pretrained_model path/to/trained_model --input path/to/input/file --output path/to/output/file
  • Test your model for video by running python test_video.py --pretrained_model path/to/trained_model --input path/to/input/file --output path/to/output/file

You could download my trained weight for SSD-Resnet50 at link

Experiments

I trained my models by using NVIDIA RTX 2080. Below is mAP evaluation for SSD-Resnet50 trained for 54 epochs on COCO val2017 dataset


SSD-Resnet50 evaluation.


SSD-Resnet50 tensorboard for training loss curve and validation mAP curve.

Results

Some predictions are shown below:

References

More Repositories

1

ASCII-generator

ASCII generator (image to text, image to image, video to video)
Python
1,522
star
2

Super-mario-bros-PPO-pytorch

Proximal Policy Optimization (PPO) algorithm for Super Mario Bros
Python
1,076
star
3

Super-mario-bros-A3C-pytorch

Asynchronous Advantage Actor-Critic (A3C) algorithm for Super Mario Bros
Python
1,035
star
4

QuickDraw

Implementation of Quickdraw - an online game developed by Google
Python
891
star
5

Flappy-bird-deep-Q-learning-pytorch

Deep Q-learning for playing flappy bird game
Python
501
star
6

Tetris-deep-Q-learning-pytorch

Deep Q-learning for playing tetris game
Python
465
star
7

AirGesture

Play games without touching keyboard
Python
398
star
8

Hierarchical-attention-networks-pytorch

Hierarchical Attention Networks for document classification
Python
381
star
9

Yolo-v2-pytorch

YOLO for object detection tasks
Python
369
star
10

Photomosaic-generator

photomosaic generator (image to image, video to video)
Python
180
star
11

Street-fighter-A3C-ICM-pytorch

Curiosity-driven Exploration by Self-supervised Prediction for Street Fighter III Third Strike
Python
160
star
12

Contra-PPO-pytorch

Proximal Policy Optimization (PPO) algorithm for Contra
Python
132
star
13

Lego-generator

Python
98
star
14

QuickDraw-AirGesture-tensorflow

Implementation of QuickDraw - an online game developed by Google, combined with AirGesture - a simple gesture recognition application
Python
93
star
15

Chrome-dino-deep-Q-learning-pytorch

Deep Q-learning for playing chrome dino game
Python
70
star
16

Deeplab-pytorch

Deeplab for semantic segmentation tasks
Python
61
star
17

Character-level-cnn-pytorch

Character-level CNN for text classification
Python
55
star
18

Very-deep-cnn-pytorch

Very deep CNN for text classification
Python
37
star
19

Character-level-cnn-tensorflow

Character-level CNN for text classification
Python
29
star
20

Sonic-PPO-pytorch

Proximal Policy Optimization (PPO) algorithm for Sonic the Hedgehog
Python
26
star
21

uvipen

22
star
22

Very-deep-cnn-tensorflow

Very deep CNN for text classification
Python
21
star
23

Color-lines-deep-Q-learning-pytorch

Python
10
star
24

MathFun

Python
9
star
25

The-beauty-of-Math

Python
7
star
26

Detectors

Python
5
star
27

Vietnam-time-use-visualization

Python
4
star