1.下载py-RFCN
git clone https://github.com/Orpine/py-R-FCN.git
2.下载微软版caffe
cd $RFCN_ROOT
git clone https://github.com/Microsoft/caffe.git
3.lib目录下编译
cd py-R-FCN/lib
make
在此,我报错了。
我的python环境:python 3.6
AttributeError: ‘dict’ object has no attribute ‘iteritems’
Python3.5中:iteritems变为items
改后正常运行。
4.编译caffe和pycaffe
cd $RFCN_ROOT/caffe
make -j8 && make pycaffe
还有一些错误:
Cannot find -lboost_python3
因为 Caffe 默认的 Python 是2.7,所以是有 lboost_python2 的,这个时候我们就需要使用 Ubuntu 自带的3版本的 Python 建立一个软连接就可以了,在命令行中输入:
手动建立连接:
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py35.so /usr/lib/x86_64-linux-gnu/libboost_python3.so
这样就OK了。
http://www.voidcn.com/article/p-fgvjvoac-bnu.html
python3编译caffe错误:cannot find -lboost_python3
/usr/lib/x86_64-linux-gnu
下只有:libboost_python-py35.so
我就改了一下:问题解决,
PYTHON_LIBRARIES := boost_python-py35
然后报错:
PyErr_Print’未定义的引用
Py_NoneStruct等未定义,修改如下,问题解决
PYTHON_LIBRARIES := boost_python-py35 python3.6m
(我两种方法都试了,不知道哪个起作用了。。)
https://github.com/BVLC/caffe/issues/6139
lib/libpng16.so.16:对‘inflateValidate@ZLIB_1.2.9’
I solved the same problem by adding the following into the Makefile.config:
LINKFLAGS := -Wl,-rpath,$(HOME)/anaconda3/lib
make all -j8
在make之后,出现了这个警告。(没有理会。。。)
/usr/bin/ld: warning: libcudart.so.8.0, needed by /usr/local/lib/libopencv_core.so, may conflict with libcudart.so.7.5
make pycaffe
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
touch python/caffe/proto/__init__.py
PROTOC (python) src/caffe/proto/caffe.proto
还以为没有编译成功,。。。结果成功了。。。额,好吧,还是不太熟练。
这个时候,import caffe是不可以的,因为还没有添加路径。
添加python路径:
sudo
export PYTHONPATH=~/caffe/python:$PYTHONPATH
source
然后,import caffe 成功。
此外,这个原本是python2的,而自己的环境是python3,有些崩溃啊!
改吧:
xrange和print这种就不说了。
import cPickle失败
原因:python2有cPickle,但是在python3下,是没有cPickle的;
解决办法:将cPickle改为pickle即可
import
还有,
python3导入时间模块是:
from time import time
使用:start = time()
运行demo:(图就不展示了)
./tools/demo_rfcn.py --net ResNet-50
运行结果如下:
Loaded network /home/xx/py-R-FCN/data/rfcn_models/resnet50_rfcn_final.caffemodel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000456.jpg
Detection took 0.104s for 300 object proposals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/000542.jpg
Detection took 0.118s for 158 object proposals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001150.jpg
Detection took 0.110s for 262 object proposals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/001763.jpg
Detection took 0.111s for 255 object proposals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo for data/demo/004545.jpg
Detection took 0.112s for 300 object proposals
但是,在训练的时候还是会有错的。
gtind = [ind for (ind, g) in sorted(enumerate(gt), key=lambda (ind, g): g[‘_ignore’]) ]
SyntaxError: invalid syntax
# python2
lambda
# python3 will be translated into:
lambda x_y: x_y[0] + x_y[1]
即,Python3中使用x_y的形式代替(x,y),使其类似于列表的形式,在调用的时候,使用x_y[index]的形式。
for k, v in a.iteritems():
AttributeError: ‘EasyDict’ object has no attribute ‘iteritems’
将iteritems()换成items()
AttributeError: ‘EasyDict’ object has no attribute ‘has_key’
https://stackoverflow.com/questions/46677942/python-dict-object-has-no-attribute-has-key
In Python 3.x, has_key() was removed,you have to use in, which is the pythonic way:
if self.groups.has_key(key):
应该改成:
if key in self.groups: