Python Forum
Running script on multiple files - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Running script on multiple files (/thread-33659.html)



Running script on multiple files - Afrodizzyjack - May-14-2021

Hello all,

I am using a package called 'augmentor' that creates augmented versions of an image. I have over 60 images and I want each image contained within its own folder with its own specific augmentations. I can't figure out how to run this script on a batch of folders where each folder contains one image. currently only works on one folder containing the image

Images are labelled m3a, m3b , m3c etc and each folder is labelled the same


import Augmentor
p = Augmentor.Pipeline("augmented_images/m3b" ) #this is where the script is directed to the folder with the image

p.rotate(probability=0.7, max_left_rotation=10, max_right_rotation=10)

p.zoom(probability=0.3, min_factor=0.5, max_factor=1)
p.flip_left_right(probability=0.4)
p.flip_top_bottom(probability=0.8)
p.skew(probability=0.5)
p.shear(probability=0.5, max_shear_left=0.5, max_shear_right=0.5)
p.random_distortion(probability=0.5, magnitude=1, grid_width=1, grid_height=1)

p.sample(50)
thank you in advanced


RE: Running script on multiple files - Yoriz - May-14-2021

Use a for loop to repeat your code on each folder.