Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
  2. from keras import backend as K
  3. K.set_image_dim_ordering('th')
  4.  
  5. #the path of images to apply augmentation on them
  6. images_path='train'
  7. #create an instance of ImageDataGenerator
  8. datagen = ImageDataGenerator(width_shift_range=0.2,
  9. height_shift_range=0.2)
  10. datagen.flow_from_directory(directory=images_path, target_size=(480,752),color_mode='grayscale', class_mode=None, save_to_dir='saved',save_prefix='keras_')
  11. img = load_img('train/images/photon10.png')
  12. x = img_to_array(img)
  13. x = x.reshape((1,) + x.shape)
  14. datagen.flow(x,batch_size=1,save_to_dir='saved',save_format='png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement