Skip to content
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

Saving all images individually generated into a new directory #159

Closed
ghost opened this issue Aug 1, 2018 · 1 comment
Closed

Saving all images individually generated into a new directory #159

ghost opened this issue Aug 1, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 1, 2018

So i understand from #38
how to save 64 augmented images of one input by the response given and if I don't include the first line as in:

images = [image] * 64 #do not include this line
images_aug = seq.augment_images(images)
for i, image_aug in enumerate(images_aug):
misc.imsave("/home/user/new_folder/image_%06d.jpg" % (i,), image_aug)

I will only get one single image of all the ones li have in the array "images".

However say I have 8 images as input and I specified rows = 8 and cols = 8 so it should create 64 different versions of each input images, so now I should be able to get 512 new images. I would like to know how I can save all those 512 images into a new directory.

@aleju
Copy link
Owner

aleju commented Aug 2, 2018

Assuming you have already a method to load your images to augment as images and an augmentation sequence as seq, then you could do the following to generate and save 64 augmented versions per image (and save them to /tmp/images_aug/<image_number>_<augmentation_number>.jpg).

import os
from scipy import misc

images = ...
seq = ...

write_to_dir = "/tmp/images_aug"
n_augs_per_image = 8 * 8

for i, image in enumerate(images):
    image_augs = seq.augment_images([image] * n_augs_per_image)
    for j, image_aug in enumerate(image_augs):
        misc.imsave(os.path.join(write_to_dir, "%06d_%02d.jpg" % (i, j)), image_aug)

misc.imsave is deprecated, but currently still useable.

@ghost ghost closed this as completed Aug 2, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant