Rotating images/arrays


#1

So in MXNet how do you rotate images? I’ve been looking at the data augmentation page and it doesn’t show rotations as a possibility, can someone explain how to do this for example with MNIST. I have them loaded as NDarrays currently.


#2

When you use ImageRecordIter then you can pass max_rotate_angle and rotate, that allows you to rotate the image data.
You can find more details here: https://mxnet.incubator.apache.org/api/python/io/io.html


#3

So I’m a bit confused how to do this. So to use ImageRecordIter I first need to make sure my file is a .rec file correct? I see on the link that there is a method MXRecordIO which can be used to do this. My question is how do I write it into a .rec file with the format that I desire. I have two separate ND arrays. The dataset is of size 60000x28x28 and the labels array is 60000, . Can you point me in the direction for how I should use MXRecordIO please. Thanks.


#4

You can use the tool im2rec: https://mxnet.incubator.apache.org/faq/recordio.html
First you need to generate an image list file and then you can create the rec.file

Once you have the rec.file you can call ImageRecordIter:

dataiter = mx.io.ImageRecordIter(
        path_imgrec="train.rec",
        data_shape=(3, 28, 28),
        batch_size=3,
        rand_crop=True,
        rand_mirror=True,
        max_random_scale=1.3,
        max_random_illumination=3,
        max_rotate_angle=10)

batch = dataiter.next()