为什么在这种图像增强中不能生成足够的图像?

时间:2019-10-03 15:07:31

标签: python python-3.x image-processing keras data-augmentation

我想使用ImageDataGenerator生成1800张图像。我从200张图像创建了一个循环,并希望从每个图像生成9张图像,总共1800张图像。 但是,当我将图像追加到列表中并打印len(list)时,我看到len是1630到1700。 发生了什么事?

    from keras.preprocessing.image import ImageDataGenerator
    datagen = ImageDataGenerator(
    rotation_range=20,
    width_shift_range=0.2,
    height_shift_range=0.2,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True,
    vertical_flip=True)

    for k in range (0,200):  
          x = mal[k]
          x = x .reshape((1,) + x.shape) #reshape (Sampkue, Nrow, Ncol, 3) 3 = R, G or B
          i = 1
          for batch in datagen.flow(x, batch_size=1, save_to_dir='Data',
                                                     save_prefix='ISIC',
                                                     save_format='jpeg'):
               i += 1
               if i > 9:
                    break  # otherwise the generator would loop 

    image_list = []
    for filename in glob.glob('Data/*.jpeg'): 
         im=Image.open(filename)
         image_list.append(np.array(im))
    print(len(image_list))
    Output is: 1658

0 个答案:

没有答案