Error in Image Augmentation Pipeline for Image Augmentation in Python

4.7k views Asked by At

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

3

There are 3 answers

3
Andrea Corbellini On BEST ANSWER

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()
0
JackDH On

I was having the same issue as you, however, I got my problem to work with the code below.

Can't tell you why it worked, but it did :)#

Also its been a while since you asked and I hope that you got your issue sorted!

import glob
import Augmentor

for filename in glob.iglob('test',recursive=True):

p = Augmentor.Pipeline(filename)

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(6)

    
    
0
Neeraj Madan On

I have got round this same error message looking at the source code. The root causes include:

A. Wrong path, more specifically formatting. If the path is wrong, I'd expect a path error rather than no images being found.

B. The other cause is lots of other different files or folders in that location that are nothing to do with images.

C. Other causes may be the notorious lag times in the cloud servers [wait of refresh then re-run]

For my issue - it was B. Other folders/formats. If you have a folder in that location which is in the "X" input / unlabelled folder. In your case: "Bennet", then it may flag up if it's read before any of the images are. Doesn't make much sense, but move the folders out, run it again just with the images and should work fine.