How to use the augmentor.misc.MiscEffect function in Augmentor

To help you get started, we’ve selected a few Augmentor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xuannianz / keras-CenterNet / train.py View on Github external
def create_generators(args):
    """
    Create generators for training and validation.

    Args
        args: parseargs object containing configuration for generators.
        preprocess_image: Function that preprocesses an image for the network.
    """
    common_args = {
        'batch_size': args.batch_size,
        'input_size': args.input_size,
    }

    # create random transform generator for augmenting training data
    if args.random_transform:
        misc_effect = MiscEffect(border_value=0)
        visual_effect = VisualEffect()
    else:
        misc_effect = None
        visual_effect = None

    if args.dataset_type == 'pascal':
        from generators.pascal import PascalVocGenerator
        train_generator = PascalVocGenerator(
            args.pascal_path,
            'trainval',
            skip_difficult=True,
            multi_scale=args.multi_scale,
            misc_effect=misc_effect,
            visual_effect=visual_effect,
            **common_args
        )
github xuannianz / EfficientDet / train.py View on Github external
def create_generators(args):
    """
    Create generators for training and validation.

    Args
        args: parseargs object containing configuration for generators.
        preprocess_image: Function that preprocesses an image for the network.
    """
    common_args = {
        'batch_size': args.batch_size,
        'phi': args.phi,
    }

    # create random transform generator for augmenting training data
    if args.random_transform:
        misc_effect = MiscEffect()
        visual_effect = VisualEffect()
    else:
        misc_effect = None
        visual_effect = None

    if args.dataset_type == 'pascal':
        from generators.pascal import PascalVocGenerator
        train_generator = PascalVocGenerator(
            args.pascal_path,
            'trainval',
            skip_difficult=True,
            misc_effect=misc_effect,
            visual_effect=visual_effect,
            **common_args
        )
github xuannianz / keras-CenterNet / augmentor / misc.py View on Github external
image, boxes = crop(image, boxes, prob=self.crop_prob)
        image, boxes = translate(image, boxes, prob=self.translate_prob, border_value=self.border_value)
        return image, boxes


if __name__ == '__main__':
    from generators.pascal import PascalVocGenerator

    train_generator = PascalVocGenerator(
        'datasets/VOC0712',
        'trainval',
        skip_difficult=True,
        batch_size=1,
        shuffle_groups=False
    )
    misc_effect = MiscEffect()
    for i in range(train_generator.size()):
        image = train_generator.load_image(i)
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        annotations = train_generator.load_annotations(i)
        boxes = annotations['bboxes']
        for box in boxes.astype(np.int32):
            cv2.rectangle(image, (box[0], box[1]), (box[2], box[3]), (0, 0, 255), 2)
        src_image = image.copy()
        # cv2.namedWindow('src_image', cv2.WINDOW_NORMAL)
        cv2.imshow('src_image', src_image)
        # image, boxes = misc_effect(image, boxes)
        image, boxes = multi_scale(image, boxes)
        image = image.copy()
        for box in boxes.astype(np.int32):
            cv2.rectangle(image, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 1)
        # cv2.namedWindow('image', cv2.WINDOW_NORMAL)
github xuannianz / EfficientDet / augmentor / misc.py View on Github external
# train_generator = PascalVocGenerator(
    #     'datasets/VOC0712',
    #     'trainval',
    #     skip_difficult=True,
    #     batch_size=1,
    #     shuffle_groups=False
    # )
    from generators.coco import CocoGenerator

    train_generator = CocoGenerator(
        '/home/adam/.keras/datasets/coco/2017_118_5',
        'train2017',
        batch_size=1,
        shuffle_groups=False
    )
    misc_effect = MiscEffect()
    for i in range(train_generator.size()):
        image = train_generator.load_image(i)
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        annotations = train_generator.load_annotations(i)
        boxes = annotations['bboxes']
        for box in boxes.astype(np.int32):
            cv2.rectangle(image, (box[0], box[1]), (box[2], box[3]), (0, 0, 255), 2)
        src_image = image.copy()
        # cv2.namedWindow('src_image', cv2.WINDOW_NORMAL)
        cv2.imshow('src_image', src_image)
        image, boxes = misc_effect(image, boxes)
        # image, boxes = multi_scale(image, boxes)
        image = image.copy()
        for box in boxes.astype(np.int32):
            cv2.rectangle(image, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 1)
        # cv2.namedWindow('image', cv2.WINDOW_NORMAL)
github xuannianz / keras-CenterNet / generators / pascal.py View on Github external
"""
        filename = self.image_names[image_index] + '.xml'
        try:
            tree = ET.parse(os.path.join(self.data_dir, 'Annotations', filename))
            return self.__parse_annotations(tree.getroot())
        except ET.ParseError as e:
            raise_from(ValueError('invalid annotations file: {}: {}'.format(filename, e)), None)
        except ValueError as e:
            raise_from(ValueError('invalid annotations file: {}: {}'.format(filename, e)), None)


if __name__ == '__main__':
    from augmentor.misc import MiscEffect
    from augmentor.color import VisualEffect

    misc_effect = MiscEffect(border_value=0)
    visual_effect = VisualEffect()

    generator = PascalVocGenerator(
        'datasets/VOC0712',
        'trainval',
        skip_difficult=True,
        misc_effect=misc_effect,
        visual_effect=visual_effect,
        batch_size=1
    )
    for inputs, targets in generator:
        print('hi')

Augmentor

Image augmentation library for Machine Learning

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis