Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Proposal Layer #219

Open
amrege opened this issue Jun 16, 2016 · 17 comments
Open

Problem with Proposal Layer #219

amrege opened this issue Jun 16, 2016 · 17 comments

Comments

@amrege
Copy link

amrege commented Jun 16, 2016

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.

@Austriker
Copy link

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

@karaspd
Copy link

karaspd commented Jun 21, 2016

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?

@Austriker
Copy link

Austriker commented Jun 21, 2016

@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 .

@karaspd
Copy link

karaspd commented Jun 21, 2016

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

kertansul added a commit to kertansul/py-faster-rcnn that referenced this issue Nov 8, 2016
@wuyuzaizai
Copy link

@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

@pchankh
Copy link

pchankh commented Dec 25, 2016

@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.

@karaspd
Copy link

karaspd commented Dec 25, 2016

@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.

@kirk86
Copy link

kirk86 commented Jan 28, 2017

@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_)

@ghost
Copy link

ghost commented Feb 5, 2017

@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'

@ghost
Copy link

ghost commented Feb 5, 2017

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.

@smfullman
Copy link

smfullman commented Feb 17, 2017

@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.

@mdadhich
Copy link

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

@smfullman
Copy link

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

@mdadhich
Copy link

I tried this, it didn't work for me, @smfullman, I have given full description of my problem #494, have a look, if you have any other suggestion.

@happynear
Copy link

@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.

fanghuaqi added a commit to foss-for-synopsys-dwc-arc-processors/py-faster-rcnn that referenced this issue May 30, 2018
Fixed error:
1. AttributeError: 'ProposalLayer' object has no attribute 'param_str_'
2. pre_nms_topN = cfg[cfg_key].RPN_PRE_NMS_TOP_N, KeyError: '1'
3. cached dataset not removed error, which will cause the test phase accuracy calculation fail

Reference:
rbgirshick#219

We need to manually remove the cached dataset in data/cache and data/VOCdevkit0712/annotations_cache when you change the train or test list in data/VOCdevkit0712/VOC0712/ImageSets/Main/

Current still facing issue
I0530 09:49:44.784348  8794 sgd_solver.cpp:144] Iteration 80, lr = 0.0005
F0530 09:50:07.775352  8794 io.cpp:87] Check failed: proto.SerializeToOstream(&output)
*** Check failure stack trace: ***
Aborted (core dumped)

Signed-off-by: Huaqi Fang <[email protected]>
@liceHuang
Copy link

@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

@liceHuang
Copy link

I sovle this problem by the follow steps:
1、use 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、rebuild caffe
3、copy 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants