基于ubuntu14.04的Mobilenet_SSD环境搭建

Data: 2017.11.22

Author: cjh

Theme: 基于ubuntu14.04的Mobilenet_SSD环境搭建

 

Caffe for SSD:https://github.com/weiliu89/caffe/tree/ssd

MobileNet-SSD:https://github.com/chuanqi305/MobileNet-SSD

 

1.      Caffe for SSD部分

git clone https://github.com/weiliu89/caffe.git  caffe-ssd

cd caffe-ssd

git checkout ssd

cpMakefile.config.example Makefile.config

vim Makefile.config

修改:

USE_CUDNN := 1

CUDA_DIR := /usr/local/cuda-8.0

WITH_PYTHON_LAYER := 1

 

错误:

基于ubuntu14.04的Mobilenet_SSD环境搭建_第1张图片

解决:

升级g++ 和gcc

sudo add-apt-repositoryppa:ubuntu-toolchain-r/test

sudo apt-get update

sudo apt-get install gcc-5 g++-5

sudo update-alternatives --install/usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

 

修改MakeFile:

-COMMON_FLAGS += $(foreachincludedir,$(INCLUDE_DIRS),-isystem $(includedir)) #- means delete

+COMMON_FLAGS += $(foreachincludedir,$(INCLUDE_DIRS),-I$(includedir)) #+ means add

 

修改MakeFile.config:

-INCLUDE_DIRS := $(PYTHON_INCLUDE)/usr/local/include

-LIBRARY_DIRS := $(PYTHON_LIB)/usr/local/lib /usr/lib

+INCLUDE_DIRS := $(PYTHON_INCLUDE)/usr/local/include /usr/include/hdf5/serial/

+LIBRARY_DIRS := $(PYTHON_LIB)/usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

 

 基于ubuntu14.04的Mobilenet_SSD环境搭建_第2张图片

执行sudo apt-get installlibopenblas-dev

 

执行:

make clean

make –j8

make py

make test -j8

 

在home/usr目录下创建data目录下载数据集图片,这里只使用voc2007

wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar

wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar

 

解压

tar -xvf VOCtrainval_06-Nov-2007.tar

tar -xvf VOCtest_06-Nov-2007.tar

 

cd ~/caffe-ssd

//这里没有使用voc2012数据,需修改create_list.sh,将2012去掉

./data/VOC0712/create_list.sh

//生成LMDB文件

./data/VOC0712/create_data.sh

下载上述预训练文件

将MobileNet-SSD复制到caffe的example目录下

git clone https://github.com/chuanqi305/MobileNet-SSD.gitmobilenet-ssd

执行:python demo.py

可看见识别效果

 

训练:

建立训练集的软连接

ln -s PATH_TO_YOUR_TRAIN_LMDB trainval_lmdb

ln -s PATH_TO_YOUR_TEST_LMDB test_lmdb

 

创建lmdb文件的同时会生成labelmap.prototxt,并将其复制到当前文件夹,即MobileNet-SSD目录

 

执行gen_model.sh生成自己的training prototxt,此时会生成example目录

 

4.Download the training weights from thelink above, and run train.sh, after about 30000 iterations, the loss should be1.5 - 2.5.

5.Run test.sh to evaluate the result.

6.Run merge_bn.py to generate your owndeploy caffemodel.

记得修改文件的对应路径和名称

基于ubuntu14.04的Mobilenet_SSD环境搭建_第3张图片

你可能感兴趣的:(linux)