Keras Image Preprocessing

后端 未结 3 1509
臣服心动
臣服心动 2020-12-07 02:36

My training images are downscaled versions of their associated HR image. Thus, the input and the output images aren\'t the same dimension. For now, I\'m using a hand-crafted

3条回答
  •  囚心锁ツ
    2020-12-07 03:41

    Yes you can use keras preprocessing function. Below some snippets to help you...

    def cropping_function(x):
        ...
        return cropped_image
    
    X_image_gen = ImageDataGenerator(preprocessing_function = cropping_function,
                                   horizontal_flip = True, 
                                   vertical_flip=True)
    X_train_flow = X_image_gen.flow(X_train, batch_size = 16, seed = 1)
    Y_image_gen = ImageDataGenerator(horizontal_flip = True, 
                                     vertical_flip=True)
    Y_train_flow = Y_image_gen.flow(y_train, batch_size = 16, seed = 1)
    train_flow = zip(X_train_flow,Y_train_flow)
    model.fit_generator(train_flow)
    

提交回复
热议问题