Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Random scaling in image augmentation #1905

Closed
vincentfung13 opened this issue Apr 20, 2016 · 5 comments
Closed

Random scaling in image augmentation #1905

vincentfung13 opened this issue Apr 20, 2016 · 5 comments

Comments

@vincentfung13
Copy link

vincentfung13 commented Apr 20, 2016

Hi all,

I am new to mxnet (to deep learning in general), and in my project I am in a situation where I need to do some scaling on the images for augmentation.

I was using the provided ImageAugmenter class for this - setting the min_random_scale and max_random_scale parameters when initialising the ImageRecordIter. However, after some digging into the source code I found what the augmenter actually does is to scale the image then crop it to fit the predefined data_shape. What I want is to randomly scale the image while retaining its content, which means an image is first scaled, then resized again to the predefined data_shape.

I managed to change the original ImageAugmenter class so it now does what I wanted, but I am not sure if it is the best place to put the changes in (potential merge conflicts if something new is added to the augmenter in the future). I can think of implementing my own augmenter but it looks like I will need to implement a new ImageRecordIter and a ImageIOParser as well, I am not sure if the effort is worth it if all I want is just to add a new augmentation approach.

Can someone point me to a right direction? Any help is much appreciated. :)

Cheers,
Vincent

@tqchen
Copy link
Member

tqchen commented Apr 26, 2016

there is a recent refactor that enables you to plugin your own augmenter by registering it.

see #1956

So now you can build your augmenter class in a new file, register it as aug_default.cc and switch to your augmenter by setting aug_seq in ImageRecordIter

@vincentfung13
Copy link
Author

Thank you for making the refactor, this looks much more feasible now. :)

@tqchen tqchen closed this as completed Apr 26, 2016
@shipengai
Copy link

Hi, how do you make your own augmenter.Can you share it with me ?

@TccccD
Copy link

TccccD commented Sep 13, 2018

Hi, @vincentfung13 @shipeng-uestc @tqchen
This seems a bit confusing, is there a simple example of using aug_seq? I want to use like"random crop - > resize", this resize method stretches the image to a square.

@thomelane
Copy link
Contributor

Hi @TccccD,

I've just replied to a similar post here which hopefully clarifies things a little more.

Aside from implementing your own augmenter and using in aug_seq, you should take a look at Gluon's Transforms. You can Compose augmentations in the order you need.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants