mdbloice / Augmentor

Image augmentation library in Python for machine learning.
https://augmentor.readthedocs.io/en/stable
MIT License
5.06k stars 865 forks source link

Augmented ground truth does not match the corresponding image when using keras_generator_from_array #207

Open eemberda opened 4 years ago

eemberda commented 4 years ago

Hi,

I used the data from https://www.kaggle.com/c/data-science-bowl-2018/data and tried to generate augmentations.

The original images and ground truth are perfectly matched: augmentor1b

I used the following pipeline:

p = Augmentor.Pipeline()
p.rotate(probability=1, max_left_rotation=5, max_right_rotation=5)
p.flip_left_right(probability=0.5)
p.zoom_random(probability=0.5, percentage_area=0.8)
p.flip_top_bottom(probability=0.5)    
g = p.keras_generator_from_array(X_train, Y_train, batch_size=1000)

When I tried to view the augmentations, the ground truth are flipped:

from random import randint

X,Y = next(g)

k = randint(0, 1000)

fig = plt.figure()
plt.subplot(2,2,1)
imshow(X[k])
plt.subplot(2,2,2)
imshow(Y[k,:,:,0])

k = randint(0, 1000)
fig = plt.figure()
plt.subplot(2,2,3)
imshow(X[k])
plt.subplot(2,2,4)
imshow(Y[k,:,:,0])

augmentor5 augmentor4

mdbloice commented 4 years ago

Hi @eemberda

Thanks for creating the issue. This should be fixed in the latest version of Augmentor, which was updated just today to 0.2.8. Use pip install --upgrade Augmentor to get the latest version.

Let me know if the issue persists, I will do my best to resolve it.

M.

Franciscose1 commented 4 years ago

Hi @mdbloice,

I have the same issue. Instaled today and have already confirmed that the version is 0.2.8.

This issue persists, confirmed using the ISIC dataset and the above code to generate.

Thank you,

Francisco