在训练Faster-RCNN模型时报出如下错误:
I0617 19:52:26.084951 19865 layer_factory.hpp:77] Creating layer input-data
I0617 19:52:26.099476 19865 net.cpp:86] Creating Layer input-data
I0617 19:52:26.099493 19865 net.cpp:382] input-data -> data
I0617 19:52:26.099517 19865 net.cpp:382] input-data -> im_info
I0617 19:52:26.099522 19865 net.cpp:382] input-data -> gt_boxes
Traceback (most recent call last):
File "./tools/train_net.py", line 112, in <module>
max_iters=args.max_iters)
File "/home/zhanghan/person/rcnn/frcnn-master/tools/../lib/fast_rcnn/train.py", line 157, in train_net
pretrained_model=pretrained_model)
File "/home/zhanghan/person/rcnn/frcnn-master/tools/../lib/fast_rcnn/train.py", line 43, in __init__
self.solver = caffe.SGDSolver(solver_prototxt)
AttributeError: can't set attribute
原因是当前所用的caffe版本和官方开源出来代码中所用的caffe版本不一致。
解决方法:
将faster rcnn中的caffe目录中:
$ROOT/caffe-fast-rcnn/include/caffe/layers/python_layers.hpp文件中的第29行:
self_.attr("phase") = static_cast<int>(this->phase_);
这一行注释掉。
然后重新编译caffe和pycaffe:
make &&make pycaffe