Search code examples
pythonmachine-learningaugmentor

Error in Image Augmentation Pipeline for Image Augmentation in Python


As per my knowledge the path is correct and I'm following the Augmentor documentation too.

Code:

import Augmentor
import os
import warnings
warnings.filterwarnings('ignore')
import keras
import glob

for img in glob.glob("C:\\Users\\Diganta\\Desktop\\Courses and Projects\\Projects\\Bennet\\irregular*.jpg"):
    p = Augmentor.Pipeline(img)
    p.rotate(probability=0.7, max_left_rotation=10, max_right_rotation=10)
    p.zoom(probability=0.5, min_factor=1.1, max_factor=1.5)
    p.sample(100)

This did run but no output folder containing the augmented images was created in the directory as per specified on the documentation of Augmentor


Solution

  • I'm not an Augmentor expert, but by looking at the source code it looks like Pipeline wants a source directory as an argument, and it will automatically find all pictures in there.

    Try passing the directory directly, without globs and loops:

    p = Augmentor.Pipeline("C:\\Users\\Diganta\\Desktop\\Courses and Projects\\Projects\\Bennet")
    p.rotate(probability=0.7, max_left_rotation=10, max_right_rotation=10)
    p.zoom(probability=0.5, min_factor=1.1, max_factor=1.5)
    p.sample(100)
    

    It also seems to me that you want to run your pipeline on all the images, not to a subset. If that's the case, then replace p.sample(100) with:

    p.sample(0)
    

    or:

    p.process()