项目作者: imistyrain

项目描述 :
跨平台编译版SSD,含有深度可分离卷积层,支持cuda10, Windows支持python3.6等,支持ssd训练预处理加速,支持MTCNN训练
高级语言: C++
项目地址: git://github.com/imistyrain/ssd.git
创建时间: 2017-10-22T05:16:19Z
项目社区:https://github.com/imistyrain/ssd

开源协议:Other

下载


ssd build across windows、Ubuntu and Mac

Update

merge caffe-ssd-optimized to speedup train preprocess

SSD is an unified framework for object detection with a single network. You can use the code to train/evaluate a network for object detection task. For more details, please refer to arXiv paper and slide. Original ssd can only be built on ubuntu and used an outdated version caffe.

How to build

Windows

  1. git clone https://github.com/imistyrain/ssd
  2. cd ssd
  3. scripts/build_win.cmd

Ubuntu & Mac

  1. git clone https://github.com/imistyrain/ssd
  2. cd ssd
  3. mkdir build
  4. cd build
  5. make -j4
  6. make install

Note: on Mac, you should pass the PYTHON_LIBRARY by runnning cmake

  1. cmake -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python2.7 ..

for python3.6

  1. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/ -DPYTHON_LIBRARY=$(python3-config --prefix)/lib/libpython3.6.dylib -DPYTHON_INCLUDE_DIR=$(python3-config --prefix)/include/python3.6m ..

otherwise you would get error:

  1. 8102 segmentation fault

what’ more, you should import caffe at the beginning of script before import cv2 to avoid the error of

  1. src/tcmalloc.cc:284] Attempt to free invalid pointer 0x7ff4821267d0

2021.01.16 add UpsampleLayer from caffe-segnet-cudnn5
2020.11.10 add focalloss layer and shuffle layer
2020.11.14 fix bug863: training error: Data layer prefetch queue empty
2020.12.13 add InterpLayer

Preparation

  1. Download fully convolutional reduced (atrous) VGGNet. By default, we assume the model is stored in $CAFFE_ROOT/models/VGGNet/
  2. Download VOC2007 and VOC2012 dataset. By default, we assume the data is stored in $HOME/data/

    1. # Download the data.
    2. cd $HOME/data
    3. wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
    4. wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
    5. wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
    6. # Extract the data.
    7. tar -xvf VOCtrainval_11-May-2012.tar
    8. tar -xvf VOCtrainval_06-Nov-2007.tar
    9. tar -xvf VOCtest_06-Nov-2007.tar
  3. Create the LMDB file.

    1. cd $CAFFE_ROOT
    2. # Create the trainval.txt, test.txt, and test_name_size.txt in data/VOC0712/
    3. ./data/VOC0712/create_list.sh
    4. # You can modify the parameters in create_data.sh if needed.
    5. # It will create lmdb files for trainval and test with encoded original image:
    6. # - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_trainval_lmdb
    7. # - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_test_lmdb
    8. # and make soft links at examples/VOC0712/
    9. ./data/VOC0712/create_data.sh

Train/Eval

  1. Train your model and evaluate the model on the fly.

    1. # It will create model definition files and save snapshot models in:
    2. # - $CAFFE_ROOT/models/VGGNet/VOC0712/SSD_300x300/
    3. # and job file, log file, and the python script in:
    4. # - $CAFFE_ROOT/jobs/VGGNet/VOC0712/SSD_300x300/
    5. # and save temporary evaluation results in:
    6. # - $HOME/data/VOCdevkit/results/VOC2007/SSD_300x300/
    7. # It should reach 77.* mAP at 120k iterations.
    8. python examples/ssd/ssd_pascal.py

    If you don’t have time to train your model, you can download a pre-trained model at here.

  2. Evaluate the most recent snapshot.

    1. # If you would like to test a model you trained, you can do:
    2. python examples/ssd/score_ssd_pascal.py
  3. Test your model using a webcam. Note: press esc to stop.

    1. # If you would like to attach a webcam to a model you trained, you can do:
    2. python examples/ssd/ssd_pascal_webcam.py

    Here is a demo video of running a SSD500 model trained on MSCOCO dataset.

  4. Check out examples/ssd_detect.ipynb or examples/ssd/ssd_detect.cpp on how to detect objects using a SSD model. Check out examples/ssd/plot_detections.py on how to plot detection results output by ssd_detect.cpp.

  5. To train on other dataset, please refer to data/OTHERDATASET for more details. We currently add support for COCO and ILSVRC2016. We recommend using examples/ssd.ipynb to check whether the new dataset is prepared correctly.

Pretained Models

  1. PASCAL VOC models:

  2. COCO models:

  3. ILSVRC models:

Train your own model

you can reference ssd-models if you want to train your model on your own data such like face detection.