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