conda create -n caffe python=2.7 -y conda activate caffe
git clone https://github.com/weiliu89/caffe cd caffe git checkout ssd
或者可以直接一步到位
git clone https://github.com/weiliu89/caffe -b ssd && cd caffe
sudo apt install -y build-essential gcc-7 g++-7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10
conda install -y cmake boost libboost boost-cpp glog gflags protobuf hdf5 lmdb leveldb libopencv scikit-image sudo apt install -y nvidia-cuda-toolkit-gcc libatlas-base-dev
mkdir build cd build cmake .. -DPYTHON_EXECUTABLE=`which python` make -j
# 下载模型 mkdir -p [/path/to/caffe]/models/VGGNet && cd [/path/to/caffe]/models/VGGNet wget https://github.com/conner99/VGGNet/raw/master/VGG_ILSVRC_16_layers_fc_reduced.caffemodel
# 下载数据集 mkdir $HOME/data && cd $HOME/data wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar 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_11-May-2012.tar tar -xvf VOCtrainval_06-Nov-2007.tar tar -xvf VOCtest_06-Nov-2007.tar
cd [/path/to/caffe] bash ./data/VOC0712/create_list.sh PYTHONPATH=$PWD/python bash ./data/VOC0712/create_data.sh
需要修改的地方
使用的GPU
如果只有一个GPU就改成gpus = "0"
调整batch_size(可选)
训练
首先需要下载模型文件
mkdir -p [/path/to/caffe]/models/VGGNet wget -O [/path/to/caffe]/models/VGGNet/VGG_ILSVRC_16_layers_fc_reduced.caffemodel https://github.com/conner99/VGGNet/raw/master/VGG_ILSVRC_16_layers_fc_reduced.caffemodel
PYTHONPATH=$PWD/python python examples/ssd/ssd_pascal.py
PYTHONPATH=$PWD/python python examples/ssd/ssd_pascal.py
PYTHONPATH=$PWD/python python examples/ssd/score_ssd_pascal.py
PYTHONPATH=$PWD/python python examples/ssd/ssd_detect.py --image_file=/home/yinziming/Downloads/a.jpg