-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow image data generator #2394
Comments
@chsasank Hi, I write some tests on the speed issue. Task: Rotate, shear and shift a 227x227x3 image If possible, I would make a PR for the new |
Hi, With my implementation,
it takes me almost same time as without any augmentation. I also found that keras implementation is distorting the colours if augmentation is used.(even if I have tested my implementation with the data I have, but I am not sure if that will suffice. Thanks, |
For rotation, it seems like your implementation is using left-top as center. You will need to do something like: o_w = float(w)/2 + 0.5
o_h = float(h)/2 + 0.5
offset_matrix = [[1, 0, o_w], [0, 1, o_h], [0, 0, 1]]
reset_matrix = [[1, 0, -o_w], [0, 1, -o_h], [0, 0, 1]]
rotation_matrix = np.dot(np.dot(offset_matrix, rotation_matrix), reset_matrix) |
That's correct, indeed all the operation seem to use left-top as centre (0,0) Check now? |
OK, I will give it a check and write some tests. |
That’d be great thanks! 👍 I’m not so good at writing tests. Thanks for your help! I'm raising a PR and added you as a collaborator to my fork.
|
By the way, I am on a busy server. Probably need someone's help to test its speed on a better environment. |
I can help, send the script I have to run on gist or somewhere. |
Hi,
I observed that image augmentation slows down the training process considerably.
When I used the following,
it took me about 300 seconds for an epoch.
When I added data augmentation,
It takes 2900 seconds per epoch. Slow down by a factor of 10!
I suspect this is due to augmentation that's happening on CPU. I have gone through source of
ImageDataGenerator
and IMHOrandom_transform
can be improved.If rotations, translations and shear are enabled, each of these are now applied one after another.
We should be able to do all of this in one step as homographic transformation. An implementation is available in skimage.
Here's an example: https://gist.github.com/chsasank/4bda6a6dc7973ae206b09134b92d20f2
Added advantage is that random zoom is just another homography.
Have a look here for visual overview of homographies.
Sasank.
The text was updated successfully, but these errors were encountered: