Esempio n. 1
0
    def _augmentation_fn(self, image, boxes):
        # there are a lot of hyperparameters here,
        # you will need to tune them all, haha

        image, boxes = random_image_crop(image,
                                         boxes,
                                         probability=0.9,
                                         min_object_covered=0.9,
                                         aspect_ratio_range=(0.93, 1.07),
                                         area_range=(0.4, 0.9),
                                         overlap_thresh=0.4)
        image = tf.image.resize_images(
            image, [self.image_height, self.image_width],
            method=RESIZE_METHOD) if self.resize else image
        # if you do color augmentations before resizing, it will be very slow!

        image = random_color_manipulations(image,
                                           probability=0.45,
                                           grayscale_probability=0.05)
        image = random_pixel_value_scale(image,
                                         minval=0.85,
                                         maxval=1.15,
                                         probability=0.2)
        boxes = random_jitter_boxes(boxes, ratio=0.01)
        image, boxes = random_flip_left_right(image, boxes)
        return image, boxes
Esempio n. 2
0
    def _augmentation_fn(self, image, boxes, labels):
        # there are a lot of hyperparameters here,
        # you will need to tune them all, haha.

        image, boxes, labels = random_image_crop(image,
                                                 boxes,
                                                 labels,
                                                 probability=0.8,
                                                 min_object_covered=0.0,
                                                 aspect_ratio_range=(0.85,
                                                                     1.15),
                                                 area_range=(0.333, 0.8),
                                                 overlap_thresh=0.3)
        image = tf.image.resize_images(image,
                                       [self.image_height, self.image_width],
                                       method=RESIZE_METHOD)
        # if you do color augmentations before resizing, it will be very slow!

        image = random_color_manipulations(image,
                                           probability=0.7,
                                           grayscale_probability=0.07)
        image = random_pixel_value_scale(image,
                                         minval=0.85,
                                         maxval=1.15,
                                         probability=0.7)
        boxes = random_jitter_boxes(boxes, ratio=0.05)
        image = random_colored_patches(image,
                                       max_patches=20,
                                       probability=0.5,
                                       size_to_image_ratio=0.1)
        image, boxes = random_flip_left_right(image, boxes)
        return image, boxes, labels