1
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
2 .假如Faster R-CNN 路径
FRCN_ROOT
3 Build the Cython modules
cd $FRCN_ROOT/lib
make
出现错误
yida@yida-X555LJ:~/py-faster-rcnn/lib$ make
python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 10, in <module>
from setuptools import setup
ImportError: No module named setuptools
make: *** [all] 错误 1
解决:
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py build
sudo python setup.py install
错误:
ImportError: No module named Cython.Distutils
解决:
sudo apt install python-pip
pip install cython
错误
python setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 58, in <module>
CUDA = locate_cuda()
File "setup.py", line 55, in locate_cuda
raise EnvironmentError('The CUDA %s path could not be located in %s' % (k, v))
EnvironmentError: The CUDA lib64 path could not be located in /usr/lib64
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
解决:
gedit 打开 setup.py
cudaconfig = {'home':home, 'nvcc':nvcc,
'include': pjoin(home, 'include'),
'lib64': pjoin(home, 'lib64')}
把上面的最后一个lib64改为lib即可
cudaconfig = {'home':home, 'nvcc':nvcc,
'include': pjoin(home, 'include'),
'lib64': pjoin(home, 'lib')}
错误
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
解决:
sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev
sudo easy_install greenlet
sudo easy_install gevent
make
编译通过
cd $FRCN_ROOT/caffe-fast-rcnn
cp Makefile.config.example Makefile.config
make -j8 && make pycaffe
错误:
.build_release/src/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^
.build_release/src/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^
.build_release/src/caffe/proto/caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.
^
error: no matching function for call to ‘google::protobuf::internal::ArenaStringPtr::GetNoArena(const string*) const’
return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
^
In file included from .build_release/src/caffe/proto/caffe.pb.h:23:0,
from .build_release/src/caffe/proto/caffe.pb.cc:5:
/usr/include/google/protobuf/arenastring.h:215:31: note: candidate: const string& google::protobuf::internal::ArenaStringPtr::GetNoArena() const
inline const ::std::string& GetNoArena() const { return *ptr_; }
^
/usr/include/google/protobuf/arenastring.h:215:31: note: candidate expects 0 arguments, 1 provided
In file included from .build_release/src/caffe/proto/caffe.pb.cc:5:0:
.build_release/src/caffe/proto/caffe.pb.h: In member function ‘const string& caffe::LayerParameter::type() const’:
解决:
protobuf版本太老
$ sudo apt-get clean
$ sudo apt-get autoclean
$ sudo apt-get autoremove
$ sudo apt-get remove --purge proto\tab 注:按tab键,补齐:protobuf-compiler
$ sudo dpkg -P protobuf-compiler
sudo apt-get install libprotobuf-dev protobuf-compiler
$wget https://github.com/google/protobuf/archive/v3.0.0.zip
$unzip v3.0.0.zip
$cd protobuf-3.0.0
下载自github的代码需要首先执行 $ ./autogen.sh 生成configure文件但是
./autogen.sh文件要在google下载,实现不了,所以手动下载gmoke-1.7.0.zip
,http://download.csdn.net/download/mister_exia/7608937 放在文件夹内
并把
./autogen.sh文件的下面几行注释掉
# Check that gmock is present. Usually it is already there since the# directory is set up as an SVN external.#if
test ! -e gmock; then# echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."# curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip# unzip -q gmock-1.7.0.zip# rm gmock-1.7.0.zip# mv gmock-1.7.0 gmock#fi执行:
unzip -q gmock-1.7.0.zip
rm gmock-1.7.0.zip
mv gmock-1.7.0 gmock
./autogen.sh
./configure
$ make
$ make check
$ sudo make install
错误
In file included from ./include/caffe/util/device_alternate.hpp:40:0,
from ./include/caffe/common.hpp:19,
from src/caffe/common.cpp:7:
./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’:
./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’
pad_h, pad_w, stride_h, stride_w));
^
./include/caffe/util/cudnn.hpp:15:28: note: in definition of macro ‘CUDNN_CHECK’
cudnnStatus_t status = condition; \
^
In file included from ./include/caffe/util/cudnn.hpp:5:0,
from ./include/caffe/util/device_alternate.hpp:40,
from ./include/caffe/common.hpp:19,
from src/caffe/common.cpp:7:
/usr/local/cuda-7.5//include/cudnn.h:803:27: note: declared here
cudnnStatus_t CUDNNWINAPI cudnnSetPooling2dDescriptor(
^
make: *** [.build_release/src/caffe/common.o] Error 1
这是因为当前版本的caffe的cudnn实现与系统所安装的cudnn的版本不一致引起的。
解决办法:
1.将./include/caffe/util/cudnn.hpp 换成最新版的caffe里的cudnn的实现,即相应的cudnn.hpp.
2.将./src/caffe/layer里的,所有以cudnn开头的文件,例如cudnn_lrn_layer.cu,cudnn_pooling_layer.cpp,cudnn_sigmoid_layer.cu。
都替换成最新版的caffe里的相应的同名文件。
rbgirshick的py-faster-rcnn实现,因为其cudnn实现为旧版本的实现,所有出现了以上问题.
又出现错误:
src/caffe/layers/cudnn_relu_layer.cpp: In member function ‘virtual void caffe::CuDNNReLULayer<Dtype>::LayerSetUp(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&)’:
src/caffe/layers/cudnn_relu_layer.cpp:16:45: error: ‘activ_desc_’ was not declared in this scope
cudnn::createActivationDescriptor<Dtype>(&activ_desc_, CUDNN_ACTIVATION_RELU);
^
make: *** [.build_release/src/caffe/layers/cudnn_relu_layer.o] 错误 1<p>
3.将./include/caffe/layers的,所有以cudnn开头的文件,例如cudnn_conv_layer.hpp,cudnn_lcn_laye.hpp</p> 都替换成最新版的caffe里的相应的同名文件
错误
训练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
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar
解压VOCdevkit
文件中
tar xvf VOCtrainval_06-Nov-2007.tar
tar xvf VOCtest_06-Nov-2007.tar
tar xvf VOCdevkit_08-Jun-2007.tar
之后可以看到
$VOCdevkit/ # development kit
$VOCdevkit/VOCcode/ # VOC utility code
$VOCdevkit/VOC2007 # image sets, annotations, etc.
建立软连接
cd $FRCN_ROOT/data //FRCN_ROOT为fasterrcnn所在目录
ln -s $VOCdevkit VOCdevkit2007
cd $FRCN_ROOT
./data/scripts/fetch_imagenet_models.sh
cd $FRCN_ROOT
./experiments/scripts/faster_rcnn_alt_opt.sh [GPU_ID] [NET] [--set ...]
我的是
cd $FRCN_ROOT
./experiments/scripts/faster_rcnn_alt_opt.sh 0 ZF pascal_voc
在py-faster-rcnn/models/pascal_voc/ZF/faster_rcnn_end2end文件夹的solver里改存储路径
snapshot_prefix: "output/faster_rcnn_end2end/voc_2007_trainval/zf_faster_rcnn"
制作自己的数据集
http://blog.csdn.net/sinat_30071459/article/details/50723212点击打开链接
训练自己的数据集
http://blog.csdn.net/sinat_30071459/article/details/50546891点击打开链接