Py-faster-rcnn: Problem with Proposal Layer

Created on 16 Jun 2016  路  17Comments  路  Source: rbgirshick/py-faster-rcnn

Hi,
I am having trouble figuring out how to fix the following problem.

Traceback (most recent call last):
File "./tools/demo.py", line 135, in
net = caffe.Net(prototxt, caffemodel, caffe.TEST)
File "/home/ubuntu/merge/new/py-faster-rcnn/tools/../lib/rpn/proposal_lay
print "\n\n", self.param_str_,"\n\n"
AttributeError: 'ProposalLayer' object has no attribute 'param_str_'

the proposal_layer file is in rpn.

Most helpful comment

Thank you @amrege I fixed it by modifying param_str_ to param_str . (in latest version of caffe it was defined param_str)

All 17 comments

Which version of caffe are you using. In the latest caffe 'param_str_' is not implemented this way in the python layer.

Hi,
I've got the same error, and I am using the latest version of caffe. Does anyone know how can I solve the issue without downgrading caffe?

@amrege @karaspd I solved this problem by forking the project py-faster-rcnn.

It works with python 3 and should work with python 2 but i haven't tested it

I have also added the layers as a PR to the official caffe but it's still pending .

Thank you @amrege I fixed it by modifying param_str_ to param_str . (in latest version of caffe it was defined param_str)

@karaspd, hi , i have the same problem, and i modified param_str_ to param_str only in proposal_layer.py, it doesn't work, please do me a favor

@karaspd , hi I have the same problem with wuyuzaizai. I am still having the problem despite doing the change of param_str_ to param_str in lib/rpn/proposal_layer.py

I1225 15:12:20.765244 2063896576 net.cpp:408] proposal -> rois
Traceback (most recent call last):
File "./tools/demo.py", line 135, in
net = caffe.Net(prototxt, caffemodel, caffe.TEST)
AttributeError: can't set attribute

Appreciate if anyone can help with the fix.

@pchankh and @wuyuzaizai Hi, I do not have my codes right now. But, I guess probably param_str_ might be used in another files as well. You can check it with ack-grep, if you are working with linux machine. sudo apt-get install ack-grep. Then find in which other files param_str_ presents.

@karaspd I think those are the files...
py-faster-rcnn/lib/rpn/anchor_target_layer.py: layer_params = yaml.load(self.param_str_)
py-faster-rcnn/lib/rpn/proposal_layer.py: layer_params = yaml.load(self.param_str_)
py-faster-rcnn/lib/rpn/proposal_target_layer.py: layer_params = yaml.load(self.param_str_)
py-faster-rcnn/lib/roi_data_layer/layer.py: layer_params = yaml.load(self.param_str_)

@karaspd After making changes in all mentioned files, I am getting below error. Please help.
Loaded network /home/ubuntu/FRCN_ROOT/data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
Traceback (most recent call last):
File "./tools/demo.py", line 142, in
_, _= im_detect(net, im)
File "/home/ubuntu/FRCN_ROOT/tools/../lib/fast_rcnn/test.py", line 154, in im_detect
blobs_out = net.forward(**forward_kwargs)
File "/home/ubuntu/FRCN_ROOT/tools/../caffe-fast-rcnn/python/caffe/pycaffe.py", line 121, in _Net_forward
self._forward(start_ind, end_ind)
File "/home/ubuntu/FRCN_ROOT/tools/../lib/rpn/proposal_layer.py", line 65, in forward
pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N
KeyError: '1'

I updated below two files also. I used ack-grep for search param_str_.
/home/ubuntu/FRCN_ROOT/caffe-fast-rcnn/.build_release/src/caffe/proto/caffe.pb.h
/home/ubuntu/FRCN_ROOT/caffe-fast-rcnn/.build_release/src/caffe/proto/caffe.pb.cc

but no success.

@saranaws07 I was running into similar issues with CUDA 8.0 and cuDNN 5.1 and followed the instructions in this comment in issue 237 by @manipopopo. From there I was getting the same KeyError: '1' problem, and realized that cfg_key was not getting set to TRAIN or TEST in self.phase. If you just want to run the demo, you can change it in proposal_layer.py manually:

#cfg_key = str(self.phase) # either 'TRAIN' or 'TEST'
cfg_key = 'TEST'

That worked fine for me in terms of executing the demo script, however it will break when you try and train a new model.

As an edit, if you want to fix this permanently, you can change caffe-fast-rcnn/include/caffe/layers/python_layer.hpp and rather than removing this line, edit it to:

self_.attr("phase") = (this->phase_);

I haven't tested this extensively, so I'm not sure if that will break anything else long term.

@smfullman Can you please tell us which file has this cfg_key ??
Thanks

@mdadhich yes, that was changed in the lib/rpn/proposal_layer.py file on line 64 in the master branch.

I tried this, it didn't work for me, @smfullman, I have given full description of my problem https://github.com/rbgirshick/py-faster-rcnn/issues/494, have a look, if you have any other suggestion.

@smfullman , @mdadhich ,

The phase in Caffe is no longer string 'TRAIN' or 'TEST'. It is 0(TRAIN) or 1(TEST) now.

So just modify

cfg_key = str(self.phase)

to

cfg_key = 'TEST' if self.phase == 1 else 'TRAIN'

can solve this issue.

@karaspd After making changes in all mentioned files, I am getting below error. Please help.
Loaded network /home/ubuntu/FRCN_ROOT/data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel
Traceback (most recent call last):
File "./tools/demo.py", line 142, in
_, _= im_detect(net, im)
File "/home/ubuntu/FRCN_ROOT/tools/../lib/fast_rcnn/test.py", line 154, in im_detect
blobs_out = net.forward(**forward_kwargs)
File "/home/ubuntu/FRCN_ROOT/tools/../caffe-fast-rcnn/python/caffe/pycaffe.py", line 121, in _Net_forward
self._forward(start_ind, end_ind)
File "/home/ubuntu/FRCN_ROOT/tools/../lib/rpn/proposal_layer.py", line 65, in forward
pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N
KeyError: '1'

if you just want to run the domo,try to modify the file proposal_layer.py in line 65 to line 68 like this:
change
pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N
post_nms_topN = cfg[cfg_key].RPN_POST_NMS_TOP_N
nms_thresh = cfg[cfg_key].RPN_NMS_THRESH
min_size = cfg[cfg_key].RPN_MIN_SIZE
to
pre_nms_topN = 6000
post_nms_topN = 300
nms_thresh = 0.7
min_size = 16

I sovle this problem by the follow steps:
1銆乽se this https://github.com/intel/caffe/blob/master/src/caffe/layers/smooth_L1_loss_layer.cpp replace the local caffe project file caffe-master/src/caffe/layers/smooth_l1_loss_layer.cpp
2銆乺ebuild caffe
3銆乧opy all content in caffe-master/Build/x64/Release/pycaffe (include file classify.py, detect.py,draw_net.py and folder caffe) to both py-faster-rcnn-master\caffe-fast-rcnn\python and Anaconda3\envs\py27\Lib\site-packages
then it works.
I have tried some other implements of smooth_l1_loss_layer.cpp can not worl,finally this work.

Was this page helpful?
0 / 5 - 0 ratings