How to do image multiple cropping in Caffe

944 views
Skip to first unread message

Yin Zheng

unread,
Oct 7, 2015, 7:17:05 AM10/7/15
to Caffe Users
Hi Guys,

In the CVPR15 paper, "Going deeper with convolutions" http://arxiv.org/abs/1409.4842, the authors mentions that: 
"Specifically, we resize the image to 4 scales where the shorter dimension (height or width) is 256, 288, 320 and 352 respectively, take the left, center and right square of these resized images (in the case of portrait images, we take the top, center and bottom squares). For each square, we then take the 4 corners and the center 224×224 crop as well as the square resized to 224×224, and their mirrored versions. This results in 4×3×6×2 = 144 crops per image."

I would like to do same multiple crop. However, in the tutorial of Caffe, it only take the crop in the center of the images. Do anyone could give me an example about how to do the preprocessing as mention above? Any comment is appreciated!

Best wishes,
Yin

mtngld

unread,
Oct 7, 2015, 5:28:59 PM10/7/15
to Caffe Users
Actually, caffe currently crops randomly during training and center cropping during testing

Take a look at data_transformer.cpp:

if (phase_ == TRAIN) {
h_off = Rand(datum_height - crop_size + 1);
w_off = Rand(datum_width - crop_size + 1);
} else {
h_off = (datum_height - crop_size) / 2;
w_off = (datum_width - crop_size) / 2;
}

I am not sure if there is a Caffe implementation of the specific cropping method of the paper but you can always do the cropping outside of caffe and pack all the variants in your DB

Yin Zheng

unread,
Oct 8, 2015, 7:42:34 AM10/8/15
to mtngld, Caffe Users
Hi Goldman,

Thanks very much for the comments! So I have to prepare different image dataset to do the testing, right?  I am afraid that could be very inefficient, because I should prepare 144 different dataset.

Best wishes,
Yin

--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/_wvSru82UrE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/a35a35b5-6d81-4938-aab2-0ba1da56260e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
------------------------------------------------------------------------------------------------------
Wir mussen wissen, Wir werden wissen.
                                  ——David Hilbert(1862~1943)
 
 

zhang wang

unread,
Oct 11, 2015, 9:37:12 AM10/11/15
to Caffe Users, goldma...@gmail.com
The version Caffe-future has a layer called "Crop", maybe helpful for you.

在 2015年10月8日星期四 UTC+8下午7:42:34,Yin Zheng写道:
Reply all
Reply to author
Forward
0 new messages