MDK

This quick start guide is for the SSD Model Development Kit (MDK) provided by GTI. The MDK contains two sets of tools, one is model development tool and the other is model conversion tool. The model development tool is in the GTI_SSD_model_development_kit_v1-0 directory, and the model conversion tool is in the GTI_SSD_conversion_tool_v1-0 directory.

To compile the caffe source code, please use the caffe-ssd source code provided in the model development tool.

Please also read GTI2801_SSD_toolset_UG_v1.0.pdf(Chinese)

File structure is recommended according to the structure of the compressed package

1. Environment installation

Please use the python 2.x。Guide for Ubuntu 16.04 and Ubuntu 15.10 can be found at Ubuntu 16.04 or 15.10 Installation Guide,For other systems, please refer to Caffe Installation

Ubuntu 16.04 is recommended, otherwise the model conversion tool may not work.

The following is the Ubuntu 16.04 environment configuration reference, excerpt from Ubuntu 16.04 or 15.10 Installation Guide.

1) Basic dependency installation:

sudo apt-get update && sudo apt-get upgrade && \
        sudo apt-get install -y --no-install-recommends \
        build-essential \
        cmake \
        git \
        wget \
        libatlas-base-dev \
        libboost-all-dev \
        libgflags-dev \
        libgoogle-glog-dev \
        libhdf5-serial-dev \
        libleveldb-dev \
        liblmdb-dev \
        libopencv-dev \
        libprotobuf-dev \
        libsnappy-dev \
        protobuf-compiler \
        python-dev \
        python-numpy \
        python-pip \
        python-setuptools \
        python-scipy \
        python-opencv \
        libopenblas-dev

2) Python2 dependency installation

Execute the following command in the caffe-ssd directory:

cd python
sudo pip install --upgrade pip && \
for req in $(cat requirements.txt) pydot; do sudo pip install $req; done

3) CUDA(NVIDIA Graphics)

Install cuda:

cd /tmp
sudo apt-get update && apt-get install wget -y --no-install-recommends && \
    wget "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb" && \
    sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb && \
    sudo apt-get update && \
    sudo apt-get install -y cuda

Install CUDNN:

wget https://developer.download.nvidia.com/compute/redist/cudnn/v5.1/cudnn-8.0-linux-x64-v5.1.tgz && \
sudo tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local && \
rm cudnn-8.0-linux-x64-v5.1.tgz && sudo ldconfig && \
cd -

4) Compile caffe-ssd

Modify the Makefile.config under the caffe-ssd directory according to your system environment, and then execute the following command to compile:

make clean
make all
make pycaffe

If there is an error in the compilation, you can adjust the Makefile.config according to the error message, and then recompile it.

2. Model training

1) Data Preparation

If you want to use custom dataset refer to Train SSD on the Custom Dataset

The SSD_typ model is applied to multi-object detection. It is recommended that no more than 20 class.

The SSD_min model is applied to single-object detection. The feature is that the model is smaller and faster.

The following is an example of VOC0712 dataset and ssd_typ.

First, go to The PASCAL Visual Object Classes Homepage to download the 2007 and 2012 dataset. Extract the data to $HOME/data/. After decompressing, the file structure is as follows:

data
  - VOCdevkit
     - VOC2007
     - VOC2012

Then execute the following command under the caffe-ssd directory:

./caffe-ssd/data/VOC0712/create_list.sh
./caffe-ssd/data/VOC0712/create_data.sh

Then, copy the files in the caffe-ssd/data/VOC0712/ directory to the $HOME/data/VOCdevkit/VOC0712/lmdb/ directory:

labelmap_voc.prototxt -> labelmap.prototxt
test_name_size.txt -> test_name_size.txt
test.txt -> test.txt
trainval.txt -> trainval.txt

Also modify the directory VOC0712_test_lmdb under $HOME/data/VOCdevkit/VOC0712/lmdb/ to test_lmdb and VOC0712_trainval_lmdb to trainval_lmdb.

Finally, modify the value of num_output of sublayer convolution_param in layer ip7_norm_mbox_conf, conv6_2_mbox_conf_1, conv7_2_mbox_conf_1 and conv8_2_mbox_conf_1 in the network description file in ssd_typ_mdk/prototxt directory to 126 (class * 6).

The dataset in GTI_SSD_DataSets_v1-0.tar.gz can be used directly without the above operation

2) Start training

Under ssd_typ_mdk, execute the following command to make a lmdb link:

ln -snf /data/VOCdevkit/VOC0712/lmdb lmdb

Before starting training, modify the following content in run_ssd_traning.sh

$TOOLS/caffe train \
--solver=$slovertxttyp \
--gpu 0 2>&1 | tee $LOG $@

to

$TOOLS/caffe train \
--solver=$slovertxttyp \
--gpu 0 \
--weights=$ssd 2>&1 | tee $LOG $@

Then execute:

source run_ssd_traning.sh

training will be started.

3. Model conversion

Due to the dependencies, it is recommended to use Ubuntu 16.04

Runtime Environment

Execute the following command in the GTI_SSD_conversion_tool_v1-0/lightsprModelConvert directory for dependencies installation:

source setting_caffe.sh
./install_opencv.sh
./install_conversion_tool.sh

Converting

Put the generated model into inputs/SSD_typ and name it SSD_typ_quant.caffemodel.

The SSD_type model is converted by following command:

make SSD_typ_vgg
make SSD_typ_ssd

The generated model is cnn_weights_SSD_typ/vgg.dat and cnn_weights_SSD_typ/ssd.bin

4. Model deploy

Replace the vgg.dat and sdd.bin under the Data/Models/gti2801/multi-object directory of Gti2801_SSD_sample by vgg.dat and sdd.bin generated by the model conversion tool. And replace labelmap.prototxt by the labelmap.prototxt under the SSD_typ_mdk/lmdb. Or modify the model and label path in the Gti2801_SSD_sample and recompile it.