Feature Extraction on Entire Image using Pre-Trained ILSVRC12 Model

623 views
Skip to first unread message

Aron Yu

unread,
Jan 13, 2015, 4:48:01 PM1/13/15
to caffe...@googlegroups.com
In the classification tutorial using the Python interface, it mentions that:

"The default is to actually do 10 predictions, cropping the center and corners of the image as well as their mirrored versions, and average over the predictions."

It goes on to say that the "center crop" can be isolated by turning off the oversample option.

My questions are (1) What's the dimension of each of these "crops"? and (2) How can I extract features from the entire image instead?

Thanks,
Aron

Bartosz Ludwiczuk

unread,
Jan 15, 2015, 11:39:24 AM1/15/15
to caffe...@googlegroups.com
1. Center crop has the same size as input to your network. Ex. Pre-trained ImageNet Model has 227x227. This parameter (I mean input size of image) is defiend in 
MODEL_FILE = '../models/bvlc_reference_caffenet/deploy.prototxt'

Moreover, line 
image_dims=(256, 256))
define what in input resolution, from which is taken central crop.So, every image is firstly resized to 256x256, then central crop is taken.

2.  If you want to extract features from entire image, you should change:
image_dims=(256, 256)) -> image_dims=(227, 227))
and
prediction = net.predict([input_image],oversample=False)
This will produce prediction using image without cropping

As you may know, extracting the features from layer is rather simple in Caffe. You simply delete all layers after selected (say fc7). Then, 
prediction
will produce the vector of features.

Aron Yu

unread,
Jan 15, 2015, 7:04:35 PM1/15/15
to caffe...@googlegroups.com
Thank you for the clarification!
Message has been deleted

Shaunak De

unread,
Jul 13, 2015, 10:56:53 AM7/13/15
to caffe...@googlegroups.com
Thank you so much for the excellent information. I just seek one clarification. When you say delete the layers after x what do you mean? Do you do this in the python interface or remove them from the model file? Could you furnish an example? Thanks
Reply all
Reply to author
Forward
0 new messages