0

The cropping strategy of caffe is to apply random-crop for training and center-crop for testing.

From experiment, I observed that accuracy of recognition improves if I can provide two cropped version (random and center) for the same image during training. These experimental data (size 100x100) are generated offline (not using caffe) by applying random and center cropping on a 115x115 sized image.

I would like to know how to perform this task in caffe?

Note: I was thinking to use 2 data layers, each with different cropping (center and random), and then perform concatenation. However, I found that caffe does not allow center crop during training.

Hasnat
  • 664
  • 1
  • 7
  • 21

1 Answers1

1

Easy answer would be to prepare another already-cropped dataset of your training data, cropped to 100x100. Then mix this dataset with your original data and train. In this way, random cropping of your new images will actually give you center cropping.

More complex way is hand-crafting your batches using caffe APIs (MATLAB and Python) and feeding the hand-crafted batches on-the-fly to the network. You can check this link for different ways to achieve this.

Community
  • 1
  • 1
Amir
  • 2,259
  • 1
  • 19
  • 29
  • I was actually following the easy way, i.e., creating cropped version by myself and augmenting it with the entire dataset. However, it simply doubles the size of the lmdb file. The Python based solution is interesting. However, there is a problem: if I use python layer then I cannot run the program on multiple gpus, i.e., reducing computation power. – Hasnat Sep 23 '16 at 08:34
  • 1
    Yes, agreed. Python Interface does not yet support multiple GPUs. But keep in mind that multiple GPUs will not increase your computational power in anyway, but will only increase your GPU RAM capacity (in case you had to use a big batch size or you are dealing with a big network which doesn't fit on a single GPU memory) – Amir Sep 29 '16 at 08:29