问题
I need to do realtime augmentation on my dataset for input to CNN, but i am having a really tough time finding suitable libraries for it. I have tried caffe
but the DataTransform
doesn't support many realtime augmentations like rotating etc. So for ease of implementation i settled with Lasagne
. But it seems that it also doesn't support realtime augmentation. I have seen some posts related to Facial Keypoints detection
where he's using Batchiterator
of nolearn.lasagne
. But i am not sure whether its realtime or not. There's no proper tutorial for it. So finally how should i do realtime augmentation in Lasagne
either through nolearn
or otherwise?
回答1:
You can use Keras framework for real time data augmentation for CNN training. Here is the example code for CIFAR10 dataset from github. You can also change it to adapt your needs or copy source code and add to lasagne project but I have not tried importing to lasagne before. Basic idea behind this is randomly augmenting data in every batch. If you have for loop of batches that fits network, you can call your augmentation function before sending data to network.
回答2:
Yes you can do real-time data augmentation in Lasagne. The simplest way is using the GaussianNoiseLayer. Simply insert it after your input layer. If Gaussian noise is not what you need, then at least you have GaussianNoiseLayer as an example for how to implement your own.
Note how the deterministic
parameter is used in Lasagne. It is off by default, and so during training the noise is added. During testing you set deterministic=True
and the augmentation is simply avoided.
回答3:
Yes, the Facial Keypoints Recognition tutorial that you mention does use real-time (on the fly) augmentation to flip the input images (and target coordinates) at random.
The nolearn-utils library has a ton of examples of iterators that do several types of augmentation. E.g. AffineTransformBatchIteratorMixin
does random affine transforms on the fly.
来源:https://stackoverflow.com/questions/34589982/realtime-data-augmentation-in-lasagne