예제 #1
0
 def create_aug_pipeline_val(input_size):
     """Image Augmentation Pipeline for Validation/Test Set."""
     p_val = Pipeline()
     # # Center Crop
     # p_val.crop_centre(probability=1, percentage_area=0.9)
     # Resize the image to the desired input size of the model
     p_val.resize(probability=1, width=input_size[0], height=input_size[1])
     return p_val
예제 #2
0
    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
예제 #3
0
# p.flip_top_bottom(probability=0.5)
#
# # 随机90, 180, 270 度旋转
# p.rotate_random_90(probability=0.75)
#
# # 随机20度内旋转,不变形, 四角填充黑色,图片大小不变
# p.rotate_without_crop(probability=0.5, max_left_rotation=20, max_right_rotation=20)
#
# # 随机20度内旋转,不变形, 四角填充黑色,图片大小调整
# p.rotate_without_crop(probability=0.5, max_left_rotation=20, max_right_rotation=20, expand=True)
#
# # 随机剪切, 中心不变
# p.crop_by_size(probability=0.5, width=100, height=100)
#
# # 随机剪切,中心变化,可调节剪切比例
# p.crop_random(probability=0.5, percentage_area=0.8)
#
# # 随机20%缩放,大小不变,图片缩小时以黑色填充
# p.zoom(probability=0.5, min_factor=0.8, max_factor=1.2)

# resize
p.resize(probability=1, width=256, height=256)

# execute and sample from the pipeline
time1 = time.time()

num_of_samples = 14200
p.sample(num_of_samples)

time2 = time.time()
print("time cost = " + str(time2 - time1) + "s")