0

I am using ImageGenerator function of tf2.4 to augment plant images, however, the generated images were filled by pixel points for the outside image boundary, which regards to its modes {"constant", "nearest", "reflect" or "wrap"} of ImageGenerator, which is not needed in my case. Regarding ImageGenerator API, there is no option to disable those modes.

Sample of the generated image that I got with ImageGenerator and given parameters.

Code:

generator = tf.keras.preprocessing.image.ImageDataGenerator(vertical_flip=45)
data = generator.flow_from_directory(
    data_dir, target_size=(IMG_SIZE, IMG_SIZE), color_mode='rgb',
    class_mode='sparse', 
    batch_size=batch_size, 
    shuffle=True,
    save_to_dir=OUTPUT_DIR, 
    save_prefix='augmented', 
    save_format='png',
    follow_links=False, 
    subset=None, 
    interpolation='nearest'
)

Result:

enter image description here

The inside area of the red drawing line is what I mentioned about filling pixel points to the outside of the image boundary.

I'm curious to know if there are any options for solving my aim?

Borin --help
  • 146
  • 2
  • 6

0 Answers0