faster rcnn with resnet101

725 views
Skip to first unread message

Xiaojiang Peng

unread,
Aug 16, 2016, 9:23:26 AM8/16/16
to Caffe Users
Hi,

I manged to run faster rcnn by finetuning the pretrained ResNet101 model (downloaded from website). And then I want to do a surgery.
However, there is a weird thing that I always get the following error even I just copy the params from input model to output model by the next python script. 

RuntimeWarning: invalid value encountered in greater_equal
  keep = np.where((ws >= min_size) & (hs >= min_size))[0]
Floating point exception (core dumped)

I have checked the problem is that 'NaN' number exists in bbox_predict layer. 
Running with the downloaded model has no problem.
The surgery model always has problem even just running the python script like the following.

python net_surgey.py  ResNet-101-model.caffemodel  ResNet-101-deploy.prototxt  ResNet-101-model-surgery.caffemodel  ResNet-101-deploy.prototxt

python script:

import numpy as np
caffe_root = '/home/lear/xpeng/code/resNet/caffe/'  #resnet supported
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
import pdb

script, in_model, in_deploy, out_model,out_deploy = sys.argv
caffe.set_mode_gpu()
caffe.set_device(0)

net = caffe.Net(in_deploy,in_model,caffe.TEST)
print("blobs {}\nparams {}".format(net.blobs.keys(), net.params.keys()))

net_out = caffe.Net(out_deploy,caffe.TEST) # in_deploy out_model,
prs = net.params.keys()
for layer in prs:
print layer
net_out.params[layer][0].data[...] = net.params[layer][0].data
try:
net_out.params[layer][1].data[...] = net.params[layer][1].data
except IndexError:
print layer+" has no bais term"
continue

pdb.set_trace()
# test the numbers
for layer in prs:
s = np.sum(net_out.params[layer][0].data.flatten()[:]-net.params[layer][0].data.flatten()[:])
print s
try:
print np.sum(net_out.params[layer][1].data.flatten()[:] - net.params[layer][1].data.flatten()[:])
print "bais found"
except IndexError:
print layer+" has no bais"
continue
net_out.save(out_model)

Anyone can help me? 

Xiaojiang Peng

unread,
Aug 22, 2016, 7:29:04 AM8/22/16
to Caffe Users
I moved to matlab code. No luck. Then I fix it by doing surgery in C++. The problem maybe that there are some differences between python, matlab and c++ in float accuracy. This is important for tiny numbers (like e-16).
Reply all
Reply to author
Forward
0 new messages