def make_pipeline(imageset_path, output_dir): """returns an augmentation pipeline for a given image set""" p = Pipeline(imageset_path, output_dir) p.random_distortion(probability=0.7, grid_width=4, grid_height=4, magnitude=8) p.flip_left_right(probability=0.5) p.flip_top_bottom(probability=0.5) p.zoom(probability=0.3, min_factor=1.1, max_factor=1.4) p.rotate(probability=0.5, max_left_rotation=10, max_right_rotation=10) return p
def create_aug_pipeline_train(input_size): """Image Augmentation Pipeline for Training Set.""" p_train = Pipeline() # Random crop p_train.add_operation(CropPercentageRange(probability=1, min_percentage_area=0.8, max_percentage_area=1, centre=False)) # Rotate the image by either 90, 180, or 270 degrees randomly p_train.rotate_random_90(probability=0.5) # Flip the image along its vertical axis p_train.flip_top_bottom(probability=0.5) # Flip the image along its horizontal axis p_train.flip_left_right(probability=0.5) # Random change brightness of the image p_train.random_brightness(probability=0.5, min_factor=0.9, max_factor=1.1) # Random change saturation of the image p_train.random_color(probability=0.5, min_factor=0.9, max_factor=1.1) # Resize the image to the desired input size of the model p_train.resize(probability=1, width=input_size[0], height=input_size[1]) return p_train