Show_augmented_Images

PHOTO EMBED

Sun Jul 31 2022 16:24:44 GMT+0000 (Coordinated Universal Time)

Saved by @mnis00014

# convert to numpy array
data = img_to_array(img)
# expand dimension to one sample
samples = expand_dims(data, 0)
# create image data augmentation generator
datagen = ImageDataGenerator(rotation_range = 40,
                             brightness_range=[0.2, 0.7],
                             width_shift_range = 0.2,
                             height_shift_range = 0.2,
                             zoom_range = 0.2,
                             horizontal_flip = True)
# prepare iterator
it = datagen.flow(samples, batch_size=1)
plt.figure(figsize=(12, 8))
# generate samples and plot
for i in range(20):
    # define subplot
    pyplot.subplot(4 , 5 , i+1)
    # generate batch of images
    batch = it.next()
    # convert to unsigned integers for viewing
    image = batch[0].astype('uint8')
    # plot raw pixel data
    pyplot.axis('off')
    # plt.tight_layout(2)
    pyplot.imshow(image)
# show the figure
plt.tight_layout(2)
fig1 = plt.gcf()
plt.show()
plt.draw()
fig1.savefig('tessstttyyy.png', dpi=100)
content_copyCOPY