Beispiel #1
0
    def __init__(self, resize_height, resize_width, mean, std, use_coordinates,
                 model, n_workers):

        self.normalizer = ImageUtilities.image_normalizer(mean, std)
        self.use_coordinates = use_coordinates

        self.resize_height = resize_height
        self.resize_width = resize_width
        self.model = model

        self.n_workers = n_workers

        self.img_resizer = ImageUtilities.image_resizer(
            self.resize_height, self.resize_width)

        if self.use_coordinates:
            self.coordinate_adder = AddCoordinates(with_r=True, usegpu=False)
    def __init__(self, resize_height, resize_width, mean,
                 std, use_coordinates, model, n_workers):

        self.normalizer = ImageUtilities.image_normalizer(mean, std)
        self.use_coordinates = use_coordinates

        self.resize_height = resize_height
        self.resize_width = resize_width
        self.model = model

        self.n_workers = n_workers

        self.img_resizer = ImageUtilities.image_resizer(
            self.resize_height, self.resize_width)

        if self.use_coordinates:
            self.coordinate_adder = ImageUtilities.coordinate_adder(
                self.resize_height, self.resize_width)
    def __init__(self, mode, labels, mean, std, image_size_height, image_size_width, annotation_size_height, annotation_size_width,
                 crop_scale, crop_ar, random_cropping=True, horizontal_flipping=True, random_jitter=True):

        self._mode = mode

        assert self._mode in ['training', 'test']

        self.n_classes = len(labels)
        self.mean = mean
        self.std = std
        self.image_size_height = image_size_height
        self.image_size_width = image_size_width
        self.random_cropping = random_cropping
        self.crop_scale = crop_scale
        self.crop_ar = crop_ar
        self.annotation_size_height = annotation_size_height
        self.annotation_size_width = annotation_size_width
        self.horizontal_flipping = horizontal_flipping
        self.random_jitter = random_jitter
        
        if self._mode == 'training':
            if self.random_cropping:
                self.image_random_cropper = ImageUtilities.image_random_cropper_and_resizer(self.image_size_height, self.image_size_width)
                self.annotation_random_cropper = ImageUtilities.image_random_cropper_and_resizer(self.annotation_size_height,
                                                                                                 self.annotation_size_width,
                                                                                                 interpolation=Image.NEAREST)
            else:
                self.image_resizer = ImageUtilities.image_resizer(self.image_size_height, self.image_size_width)
                self.annotation_resizer = ImageUtilities.image_resizer(self.annotation_size_height, self.annotation_size_width,
                                                                       interpolation=Image.NEAREST)
            if self.horizontal_flipping:
                self.horizontal_flipper = ImageUtilities.image_random_horizontal_flipper()
            if self.random_jitter:
                self.random_jitterer = transforms.ColorJitter(brightness=0.4, contrast=0.4, saturation=0.4, hue=0.1)
        else:
            self.image_resizer = ImageUtilities.image_resizer(self.image_size_height, self.image_size_width)
            self.annotation_resizer = ImageUtilities.image_resizer(self.annotation_size_height, self.annotation_size_width,
                                                                   interpolation=Image.NEAREST)

        self.image_normalizer = ImageUtilities.image_normalizer(self.mean, self.std)
    def __init__(self, resize_height, resize_width, mean, std, model):
        self.normalizer = ImageUtilities.image_normalizer(mean, std)

        self.resize_height = resize_height
        self.resize_width = resize_width
        self.model = model
Beispiel #5
0
    def __init__(self,
                 mode,
                 n_classes,
                 max_n_objects,
                 mean,
                 std,
                 image_height,
                 image_width,
                 random_hor_flipping=True,
                 random_ver_flipping=True,
                 random_transposing=True,
                 random_90x_rotation=True,
                 random_rotation=True,
                 random_color_jittering=True,
                 random_grayscaling=True,
                 random_channel_swapping=True,
                 random_gamma=True,
                 random_resolution=True):

        self._mode = mode
        self.n_classes = n_classes
        self.max_n_objects = max_n_objects

        assert self._mode in ['training', 'test']

        self.mean = mean
        self.std = std
        self.image_height = image_height
        self.image_width = image_width

        self.random_horizontal_flipping = random_hor_flipping
        self.random_vertical_flipping = random_ver_flipping
        self.random_transposing = random_transposing
        self.random_90x_rotation = random_90x_rotation
        self.random_rotation = random_rotation
        self.random_color_jittering = random_color_jittering
        self.random_grayscaling = random_grayscaling
        self.random_channel_swapping = random_channel_swapping
        self.random_gamma = random_gamma
        self.random_resolution = random_resolution

        if self._mode == 'training':
            if self.random_horizontal_flipping:
                self.horizontal_flipper = IU.image_random_horizontal_flipper()
            if self.random_vertical_flipping:
                self.vertical_flipper = IU.image_random_vertical_flipper()
            if self.random_transposing:
                self.transposer = IU.image_random_transposer()
            if self.random_rotation:
                self.image_rotator = IU.image_random_rotator(random_bg=True)
                self.annotation_rotator = IU.image_random_rotator(
                    Image.NEAREST, random_bg=False)
            if self.random_90x_rotation:
                self.image_rotator_90x = IU.image_random_90x_rotator()
                self.annotation_rotator_90x = IU.image_random_90x_rotator(
                    Image.NEAREST)
            if self.random_color_jittering:
                self.color_jitter = IU.image_random_color_jitter(
                    brightness=0.4, contrast=0.4, saturation=0.4, hue=0.2)
            if self.random_grayscaling:
                self.grayscaler = IU.image_random_grayscaler(p=0.3)
            if self.random_channel_swapping:
                self.channel_swapper = IU.image_random_channel_swapper(p=0.5)
            if self.random_gamma:
                self.gamma_adjuster = IU.image_random_gamma([0.7, 1.3], gain=1)
            if self.random_resolution:
                self.resolution_degrader = IU.image_random_resolution(
                    [0.7, 1.3])

            self.img_resizer = IU.image_resizer(self.image_height,
                                                self.image_width)
            self.ann_resizer = IU.image_resizer(self.image_height,
                                                self.image_width,
                                                interpolation=Image.NEAREST)
        else:
            self.img_resizer = IU.image_resizer(self.image_height,
                                                self.image_width)
            self.ann_resizer = IU.image_resizer(self.image_height,
                                                self.image_width,
                                                interpolation=Image.NEAREST)

        self.image_normalizer = IU.image_normalizer(self.mean, self.std)
Beispiel #6
0
    def __init__(self,
                 mode,
                 n_classes,
                 max_n_objects,
                 mean,
                 std,
                 image_height,
                 image_width,
                 random_hor_flipping=True,
                 random_ver_flipping=True,
                 random_90x_rotation=True,
                 random_rotation=True,
                 random_color_jittering=True,
                 use_coordinates=False):

        self._mode = mode
        self.n_classes = n_classes
        self.max_n_objects = max_n_objects

        assert self._mode in ['training', 'test']

        self.mean = mean
        self.std = std
        self.image_height = image_height
        self.image_width = image_width

        self.random_horizontal_flipping = random_hor_flipping
        self.random_vertical_flipping = random_ver_flipping
        self.random_90x_rotation = random_90x_rotation
        self.random_rotation = random_rotation
        self.random_color_jittering = random_color_jittering

        self.use_coordinates = use_coordinates

        if self._mode == 'training':
            if self.random_horizontal_flipping:
                self.horizontal_flipper = IU.image_random_horizontal_flipper()
            if self.random_vertical_flipping:
                self.vertical_flipper = IU.image_random_vertical_flipper()
            if self.random_90x_rotation:
                self.rotator_90x = IU.image_random_90x_rotator()
            if self.random_rotation:
                self.rotator = IU.image_random_rotator(expand=True)
            if self.random_color_jittering:
                self.color_jitter = IU.image_random_color_jitter(
                    brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1)

            self.img_resizer = IU.image_resizer(self.image_height,
                                                self.image_width)
            self.ann_resizer = IU.image_resizer(self.image_height,
                                                self.image_width,
                                                interpolation=Image.NEAREST)
        else:
            self.img_resizer = IU.image_resizer(self.image_height,
                                                self.image_width)
            self.ann_resizer = IU.image_resizer(self.image_height,
                                                self.image_width,
                                                interpolation=Image.NEAREST)

        self.image_normalizer = IU.image_normalizer(self.mean, self.std)

        if self.use_coordinates:
            self.coordinate_adder = IU.coordinate_adder(
                self.image_height, self.image_width)