The code im trying to use to augment multiple images from my directory but when i run the code it only selects 1 image from the directory to augment. I want to augment all 15 images.
import keras import cv2 import os import glob from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img datagen = ImageDataGenerator(rotation_range =15, width_shift_range = 0.2, height_shift_range = 0.2, rescale=1./255, zoom_range=0.2, horizontal_flip = True, fill_mode = 'constant', data_format='channels_last', ) img_dir = "C:/Users/RODNEY/Desktop/School" #Enter Directory of all images data_path = os.path.join(img_dir,'*g') files = glob.glob(data_path) data = [] for f1 in files: img = cv2.imread(f1) data.append(img) x = img_to_array(img) x = x.reshape((1,) + x.shape) i = 0 path, dirs, files = next(os.walk("C:/Users/RODNEY/Desktop/School/")) file_count = len(files) #to find number of files in folder for data in datagen.flow (x, batch_size=1, save_to_dir =r'preview',save_prefix="School",save_format='png'): i+=1 if i==5: break
https://stackoverflow.com/questions/66501957/data-augmentation-only-augments-1-image-from-directory March 06, 2021 at 11:03AM
没有评论:
发表评论