Created
March 11, 2019 11:25
-
-
Save PallawiSinghal/48062dd653bb51cd4cb61bef6818d484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import all dependencies | |
import PIL | |
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img | |
import numpy as np | |
datagen = ImageDataGenerator( | |
rotation_range=40, | |
width_shift_range=0.2, | |
height_shift_range=0.2, | |
rescale=1./255, | |
shear_range=0.2, | |
zoom_range=0.2, | |
horizontal_flip=True, | |
fill_mode='nearest') | |
if __name__ == '__main__': | |
image_file_path = "dataset/train/dog/dog.01.jpg" | |
img = load_img(image_file_path) | |
image_array = img_to_array(img) | |
x = image_array.reshape((1,) + image_array.shape) | |
# compute quantities required for featurewise normalization | |
# (std, mean, and principal components if ZCA whitening is applied) | |
datagen.fit(x) | |
i = 0 | |
for batch in datagen.flow(x,save_to_dir='path_augmented_image_folder', save_prefix='Dog', save_format='jpeg'): | |
i += 1 | |
print ("Image count--->",i) | |
if i >= 20: | |
print ("Saved 20 augmented images succesfully") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment