Do i need same preprocessing with RCCN to use for feature extraction as BVLC_REFERENCE model?

141 views
Skip to first unread message

Eren Gölge

unread,
Nov 20, 2014, 8:00:08 PM11/20/14
to caffe...@googlegroups.com
I try to use RCNN fc7 layer for visual feature extractor. I used the following code from the filter visualization example. 

...
net
= caffe.Classifier(caffe_root + 'models/bvlc_reference_rcnn_ilsvrc13/deploy.prototxt',
                       caffe_root
+ 'models/bvlc_reference_rcnn_ilsvrc13/bvlc_reference_rcnn_ilsvrc13.caffemodel')
net
.set_phase_test()
#net.set_mode_cpu()
net
.set_mode_gpu()
# input preprocessing: 'data' is the name of the input blob == net.inputs[0]
net
.set_mean('data', np.load(caffe_root + 'python/caffe/imagenet/ilsvrc_2012_mean.npy'))  # ImageNet mean
net
.set_raw_scale('data', 255)  # the reference model operates on images in [0,255] range instead of [0,1]
net
.set_channel_swap('data', (2,1,0))  # the reference model has channels in BGR order instead of RGB


for count,img_path in enumerate(img_paths):
   
if count % 1000 ==  0:
       
print count , ' --- ', len(img_paths)
   
try:
        net
.predict([caffe.io.load_image(img_path)])
       
#save_feature(img_path, scores,  '_coffe_scores.txt')
        feat
= net.blobs['fc7'].data[4,:]
        save_feature
(img_path, feat, '_rcnn_feat_fc7.txt')
   
except:
        shutil
.move(img_path, '/media/Elements/Data/Rotten_Images/')
       
print img_path

I am applying same mean removal for each image as the BLVC_REFERENCE_MODEL's Filter Visualization tutorial. Is it valid for RCNN too or do I need some settings different then the pointed example? Do you see something wrong about the above code?
Reply all
Reply to author
Forward
0 new messages