/ssd.pytorch

A PyTorch Implementation of Single Shot MultiBox Detector

Primary LanguagePythonMIT LicenseMIT

SSD: Single Shot MultiBox Object Detector, in PyTorch

A PyTorch implementation of Single Shot MultiBox Detector from the 2016 paper by Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang, and Alexander C. Berg. The official and original Caffe code can be found here.

Table of Contents

       

Enironment

  • 安装或者升级最新版pytorch Install PyTorch python 3以上

  • 安装可视化模块visdom(VOC数据集可用)

    We now support Visdom for real-time loss visualization during training!

    First install Python server and client 
    $ pip install visdom
    
    Start the server (probably in a screen or tmux)
    $ python -m visdom.server
    
    Then (during training) navigate to http://localhost:8097/ 
    

Datasets

VOC Dataset

Download VOC2007 trainval & test
# specify a directory for dataset to be downloaded into, else default is ~/data/
	$ sh data/scripts/VOC2007.sh DWONLOAD_PATH
下载数据好后会自动删除压缩文件
Download VOC2012 trainval
# specify a directory for dataset to be downloaded into, else default is ~/data/
	$ sh data/scripts/VOC2012.sh DWONLOAD_PATH

Training SSD

  • 下载预训练网络参数

First download the fc-reduced VGG-16 PyTorch base network weights at: https://s3.amazonaws.com/amdegroot-models/vgg16_reducedfc.pth

By default, we assume you have downloaded the file in the ssd.pytorch/weights dir:

	$ mkdir weights
	$ cd weights
	$ wget https://s3.amazonaws.com/amdegroot-models/vgg16_reducedfc.pth
  • 训练模型

To train SSD using the train script simply specify the parameters listed in train.py as a flag or manually change them.

	$ python train.py --voc_root DATASET_PATH

Evaluation

To evaluate a trained network:

	$ python eval.py --voc_root DATASET_PATH

You can specify the parameters listed in the eval.py file by flagging them or manually changing them.

Demos

Use a pre-trained SSD network for detection

Download a pre-trained network

SSD results on multiple datasets

Try the demo notebook

  • Make sure you have jupyter notebook installed.
  • Two alternatives for installing jupyter notebook:
    1. If you installed PyTorch with conda (recommended), then you should already have it. (Just navigate to the ssd.pytorch cloned repo and run): jupyter notebook

    2. If using pip:

# make sure pip is upgraded
pip3 install --upgrade pip
# install jupyter notebook
pip install jupyter
# Run this inside ssd.pytorch
jupyter notebook