training data augmentation in caffe along with its multilabel

1.2k views Asked by At

How to randomly crop training images along with its position label.

I'm preprocessing images data and its labels for caffe input. I want to crop my training images randomly online (when caffe running) and I know caffe provide a random crop param in layer random crop. The issues is that my label of each corresponding image is variant when image is transformed. So in this way I have to change my label together with transformed image. I try to search my issue long time, but no use. Then I realized maybe there were two ways to solve the issues:

  1. get the offset of random crop image on original image. But I googled it with no answer about it.
  2. I'll specify the random offset online, then crop image by the specific offset crop specific offset. But how can i generate a random number when caffe training time.
  3. I kown preprocessing the random crop image and its label offline may be a workable method. However, it will occupied considerable space of disk, for my data-set for training is too large.

my position corresponding label: I split each of training image as 10x10=100 grids. the label is the index of grid for specific keypoint in image. for instance, the label will be 11, when my head key-point is at position of <2th row, 1th col> grid of image.

1

There are 1 answers

2
Shai On BEST ANSWER

You can use a "Python" layer for this task, as you already pointed out (and I suppose this is the easiest way around).
If you are concerned with running time of this layer, you can make it multi-thread: have the layer invoke several threads to crop images and re-compute their labels. These threads will run at the background and should be able to provide the net with enough data in time for the next mini batch.

See python threading module for the Thread class. You might also find it convenient to use Queue class to sync the threads and the main input layer.