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