当前位置: 首页>>代码示例>>Python>>正文


Python augmenters.Fliplr方法代码示例

本文整理汇总了Python中imgaug.augmenters.Fliplr方法的典型用法代码示例。如果您正苦于以下问题:Python augmenters.Fliplr方法的具体用法?Python augmenters.Fliplr怎么用?Python augmenters.Fliplr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imgaug.augmenters的用法示例。


在下文中一共展示了augmenters.Fliplr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def __init__(self, dataset_path,scale,k_fold_test=1, mode='train'):
        super().__init__()
        self.mode = mode
        self.img_path=dataset_path+'/img'
        self.mask_path=dataset_path+'/mask'
        self.image_lists,self.label_lists=self.read_list(self.img_path,k_fold_test=k_fold_test)
        self.flip =iaa.SomeOf((2,4),[
             iaa.Fliplr(0.5),
             iaa.Flipud(0.5),
             iaa.Affine(rotate=(-30, 30)),
             iaa.AdditiveGaussianNoise(scale=(0.0,0.08*255))], random_order=True)
        # resize
        self.resize_label = transforms.Resize(scale, Image.NEAREST)
        self.resize_img = transforms.Resize(scale, Image.BILINEAR)
        # normalization
        self.to_tensor = transforms.ToTensor() 
开发者ID:FENGShuanglang,项目名称:Pytorch_Medical_Segmention_Template,代码行数:18,代码来源:Linear_lesion.py

示例2: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def main():
    img = data.astronaut()
    img = ia.imresize_single_image(img, (64, 64))
    aug = iaa.Fliplr(0.5)
    unseeded1 = aug.draw_grid(img, cols=8, rows=1)
    unseeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1000)
    seeded1 = aug.draw_grid(img, cols=8, rows=1)
    seeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1000)
    reseeded1 = aug.draw_grid(img, cols=8, rows=1)
    reseeded2 = aug.draw_grid(img, cols=8, rows=1)

    iarandom.seed(1001)
    reseeded3 = aug.draw_grid(img, cols=8, rows=1)
    reseeded4 = aug.draw_grid(img, cols=8, rows=1)

    all_rows = np.vstack([unseeded1, unseeded2, seeded1, seeded2, reseeded1, reseeded2, reseeded3, reseeded4])
    ia.imshow(all_rows) 
开发者ID:aleju,项目名称:imgaug,代码行数:23,代码来源:check_seed.py

示例3: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def __init__(self, augmentation_rate):
        self.augs = iaa.Sometimes(
            augmentation_rate,
            iaa.SomeOf(
                (4, 7),
                [
                    iaa.Affine(rotate=(-10, 10)),
                    iaa.Fliplr(0.2),
                    iaa.AverageBlur(k=(2, 10)),
                    iaa.Add((-10, 10), per_channel=0.5),
                    iaa.Multiply((0.75, 1.25), per_channel=0.5),
                    iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5),
                    iaa.Crop(px=(0, 20))
                ],
                random_order=True
            )
        ) 
开发者ID:Giphy,项目名称:celeb-detection-oss,代码行数:19,代码来源:img_augmentor.py

示例4: img_aug

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def img_aug(img, mask):
    mask = np.where(mask > 0, 0, 255).astype(np.uint8)
    flipper = iaa.Fliplr(0.5).to_deterministic()
    mask = flipper.augment_image(mask)
    img = flipper.augment_image(img)
    vflipper = iaa.Flipud(0.5).to_deterministic()
    img = vflipper.augment_image(img)
    mask = vflipper.augment_image(mask)
    if random.random() < 0.5:
        rot_time = random.choice([1, 2, 3])
        for i in range(rot_time):
            img = np.rot90(img)
            mask = np.rot90(mask)
    if random.random() < 0.5:
        translater = iaa.Affine(translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
                                scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
                                shear=(-8, 8),
                                cval=(255)
                                ).to_deterministic()
        img = translater.augment_image(img)
        mask = translater.augment_image(mask)
    # if random.random() < 0.5:
    #     img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
    mask = np.where(mask > 0, 0, 255).astype(np.uint8)
    return img, mask 
开发者ID:Tshzzz,项目名称:jinnan_unet_baseline,代码行数:27,代码来源:datasets.py

示例5: create_augmenter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def create_augmenter(stage: str = "train"):
        if stage == "train":
            return iaa.Sequential([
                iaa.Fliplr(0.5),
                iaa.CropAndPad(px=(0, 112), sample_independently=False),
                iaa.Affine(translate_percent={"x": (-0.4, 0.4), "y": (-0.4, 0.4)}),
                iaa.SomeOf((0, 3), [
                    iaa.AddToHueAndSaturation((-10, 10)),
                    iaa.Affine(scale={"x": (0.9, 1.1), "y": (0.9, 1.1)}),
                    iaa.GaussianBlur(sigma=(0, 1.0)),
                    iaa.AdditiveGaussianNoise(scale=0.05 * 255)
                ])
            ])
        elif stage == "val":
            return iaa.Sequential([
                iaa.CropAndPad(px=(0, 112), sample_independently=False),
                iaa.Affine(translate_percent={"x": (-0.4, 0.4), "y": (-0.4, 0.4)}),
            ])
        elif stage == "test":
            return iaa.Sequential([]) 
开发者ID:csvance,项目名称:keras-mobile-detectnet,代码行数:22,代码来源:generator.py

示例6: augment_flip

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def augment_flip(image, bbox):
    aug = iaa.Sequential([iaa.Fliplr(1.0)])

    bbs = ia.BoundingBoxesOnImage([
        ia.BoundingBox(x1=bbox[0], y1=bbox[1], x2=bbox[2], y2=bbox[3])], shape=image.shape)

    aug = aug.to_deterministic()
    image_aug = aug.augment_image(image)
    image_aug = image_aug.copy()
    bbs_aug = aug.augment_bounding_boxes([bbs])[0]
    b = bbs_aug.bounding_boxes
    bbs_aug = [b[0].x1, b[0].y1, b[0].x2, b[0].y2]
    bbs_aug = np.asarray(bbs_aug)

    bbs_aug[0] = bbs_aug[0] if bbs_aug[0] > 0 else 0
    bbs_aug[1] = bbs_aug[1] if bbs_aug[1] > 0 else 0
    bbs_aug[2] = bbs_aug[2] if bbs_aug[2] < size else size
    bbs_aug[3] = bbs_aug[3] if bbs_aug[3] < size else size
    return image_aug, bbs_aug 
开发者ID:MahmudulAlam,项目名称:Unified-Gesture-and-Fingertip-Detection,代码行数:21,代码来源:augmentation.py

示例7: flip

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def flip(image, bbox):
    aug = iaa.Sequential([iaa.Fliplr(1.0)])

    bbs = ia.BoundingBoxesOnImage([
        ia.BoundingBox(x1=bbox[0], y1=bbox[1], x2=bbox[2], y2=bbox[3])], shape=image.shape)

    aug = aug.to_deterministic()
    image_aug = aug.augment_image(image)
    image_aug = image_aug.copy()
    bbs_aug = aug.augment_bounding_boxes([bbs])[0]
    b = bbs_aug.bounding_boxes
    bbs_aug = [b[0].x1, b[0].y1, b[0].x2, b[0].y2]
    bbs_aug = np.asarray(bbs_aug)

    bbs_aug[0] = bbs_aug[0] if bbs_aug[0] > 0 else 0
    bbs_aug[1] = bbs_aug[1] if bbs_aug[1] > 0 else 0
    bbs_aug[2] = bbs_aug[2] if bbs_aug[2] < size else size
    bbs_aug[3] = bbs_aug[3] if bbs_aug[3] < size else size
    return image_aug, bbs_aug 
开发者ID:MahmudulAlam,项目名称:Unified-Gesture-and-Fingertip-Detection,代码行数:21,代码来源:augmentation.py

示例8: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def main():
    img = data.astronaut()
    img = misc.imresize(img, (64, 64))
    aug = iaa.Fliplr(0.5)
    unseeded1 = aug.draw_grid(img, cols=8, rows=1)
    unseeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1000)
    seeded1 = aug.draw_grid(img, cols=8, rows=1)
    seeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1000)
    reseeded1 = aug.draw_grid(img, cols=8, rows=1)
    reseeded2 = aug.draw_grid(img, cols=8, rows=1)

    ia.seed(1001)
    reseeded3 = aug.draw_grid(img, cols=8, rows=1)
    reseeded4 = aug.draw_grid(img, cols=8, rows=1)

    all_rows = np.vstack([unseeded1, unseeded2, seeded1, seeded2, reseeded1, reseeded2, reseeded3, reseeded4])
    misc.imshow(all_rows) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:23,代码来源:check_seed.py

示例9: example_show

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def example_show():
    print("Example: Show")
    from imgaug import augmenters as iaa

    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
    seq = iaa.Sequential([iaa.Fliplr(0.5), iaa.GaussianBlur((0, 3.0))])

    # show an image with 8*8 augmented versions of image 0
    seq.show_grid(images[0], cols=8, rows=8)

    # Show an image with 8*8 augmented versions of image 0 and 8*8 augmented
    # versions of image 1. The identical augmentations will be applied to
    # image 0 and 1.
    seq.show_grid([images[0], images[1]], cols=8, rows=8)

# this example is no longer necessary as the library can now handle 2D images 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:18,代码来源:test_readme_examples.py

示例10: example_single_augmenters

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def example_single_augmenters():
    print("Example: Single Augmenters")
    from imgaug import augmenters as iaa
    images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)

    flipper = iaa.Fliplr(1.0) # always horizontally flip each input image
    images[0] = flipper.augment_image(images[0]) # horizontally flip image 0

    vflipper = iaa.Flipud(0.9) # vertically flip each input image with 90% probability
    images[1] = vflipper.augment_image(images[1]) # probably vertically flip image 1

    blurer = iaa.GaussianBlur(3.0)
    images[2] = blurer.augment_image(images[2]) # blur image 2 by a sigma of 3.0
    images[3] = blurer.augment_image(images[3]) # blur image 3 by a sigma of 3.0 too

    translater = iaa.Affine(translate_px={"x": -16}) # move each input image by 16px to the left
    images[4] = translater.augment_image(images[4]) # move image 4 to the left

    scaler = iaa.Affine(scale={"y": (0.8, 1.2)}) # scale each input image to 80-120% on the y axis
    images[5] = scaler.augment_image(images[5]) # scale image 5 by 80-120% on the y axis 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:22,代码来源:test_readme_examples.py

示例11: _rectify_augmenter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def _rectify_augmenter(self, augment):
        import netharn as nh
        if augment is True:
            augment = 'simple'

        if not augment:
            augmenter = None
        elif augment == 'simple':
            augmenter = iaa.Sequential([
                iaa.Crop(percent=(0, .2)),
                iaa.Fliplr(p=.5)
            ])
        elif augment == 'complex':
            augmenter = iaa.Sequential([
                iaa.Sometimes(0.2, nh.data.transforms.HSVShift(hue=0.1, sat=1.5, val=1.5)),
                iaa.Crop(percent=(0, .2)),
                iaa.Fliplr(p=.5)
            ])
        else:
            raise KeyError('Unknown augmentation {!r}'.format(augment))
        return augmenter 
开发者ID:Erotemic,项目名称:netharn,代码行数:23,代码来源:sseg_camvid.py

示例12: _rectify_augmenter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def _rectify_augmenter(self, augmenter):
        import netharn as nh
        if augmenter is True:
            augmenter = 'simple'

        if not augmenter:
            augmenter = None
        elif augmenter == 'simple':
            augmenter = iaa.Sequential([
                iaa.Crop(percent=(0, .2)),
                iaa.Fliplr(p=.5)
            ])
        elif augmenter == 'complex':
            augmenter = iaa.Sequential([
                iaa.Sometimes(0.2, nh.data.transforms.HSVShift(hue=0.1, sat=1.5, val=1.5)),
                iaa.Crop(percent=(0, .2)),
                iaa.Fliplr(p=.5)
            ])
        else:
            raise KeyError('Unknown augmentation {!r}'.format(self.augment))
        return augmenter 
开发者ID:Erotemic,项目名称:netharn,代码行数:23,代码来源:segmentation.py

示例13: _load_augmentation_aug_geometric

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def _load_augmentation_aug_geometric():
    return iaa.OneOf([
        iaa.Sequential([iaa.Fliplr(0.5), iaa.Flipud(0.2)]),
        iaa.CropAndPad(percent=(-0.05, 0.1),
                       pad_mode='constant',
                       pad_cval=(0, 255)),
        iaa.Crop(percent=(0.0, 0.1)),
        iaa.Crop(percent=(0.3, 0.5)),
        iaa.Crop(percent=(0.3, 0.5)),
        iaa.Crop(percent=(0.3, 0.5)),
        iaa.Sequential([
            iaa.Affine(
                    # scale images to 80-120% of their size,
                    # individually per axis
                    scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
                    # translate by -20 to +20 percent (per axis)
                    translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
                    rotate=(-45, 45),  # rotate by -45 to +45 degrees
                    shear=(-16, 16),  # shear by -16 to +16 degrees
                    # use nearest neighbour or bilinear interpolation (fast)
                    order=[0, 1],
                    # if mode is constant, use a cval between 0 and 255
                    mode='constant',
                    cval=(0, 255),
                    # use any of scikit-image's warping modes
                    # (see 2nd image from the top for examples)
            ),
            iaa.Sometimes(0.3, iaa.Crop(percent=(0.3, 0.5)))])
    ]) 
开发者ID:divamgupta,项目名称:image-segmentation-keras,代码行数:31,代码来源:augmentation.py

示例14: main

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def main():
    image = data.astronaut()
    print("image shape:", image.shape)
    print("Press ENTER or wait %d ms to proceed to the next image." % (TIME_PER_STEP,))

    children_all = [
        ("hflip", iaa.Fliplr(1)),
        ("add", iaa.Add(50)),
        ("dropout", iaa.Dropout(0.2)),
        ("affine", iaa.Affine(rotate=35))
    ]

    channels_all = [
        None,
        0,
        [],
        [0],
        [0, 1],
        [1, 2],
        [0, 1, 2]
    ]

    cv2.namedWindow("aug", cv2.WINDOW_NORMAL)
    cv2.imshow("aug", image[..., ::-1])
    cv2.waitKey(TIME_PER_STEP)

    for children_title, children in children_all:
        for channels in channels_all:
            aug = iaa.WithChannels(channels=channels, children=children)
            img_aug = aug.augment_image(image)
            print("dtype", img_aug.dtype, "averages", np.average(img_aug, axis=tuple(range(0, img_aug.ndim-1))))

            title = "children=%s | channels=%s" % (children_title, channels)
            img_aug = ia.draw_text(img_aug, x=5, y=5, text=title)

            cv2.imshow("aug", img_aug[..., ::-1])  # here with rgb2bgr
            cv2.waitKey(TIME_PER_STEP) 
开发者ID:aleju,项目名称:imgaug,代码行数:39,代码来源:check_withchannels.py

示例15: example_simple_training_setting

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Fliplr [as 别名]
def example_simple_training_setting():
    print("Example: Simple Training Setting")
    import numpy as np
    import imgaug.augmenters as iaa

    def load_batch(batch_idx):
        # dummy function, implement this
        # Return a numpy array of shape (N, height, width, #channels)
        # or a list of (height, width, #channels) arrays (may have different image
        # sizes).
        # Images should be in RGB for colorspace augmentations.
        # (cv2.imread() returns BGR!)
        # Images should usually be in uint8 with values from 0-255.
        return np.zeros((128, 32, 32, 3), dtype=np.uint8) + (batch_idx % 255)

    def train_on_images(images):
        # dummy function, implement this
        pass

    # Pipeline:
    # (1) Crop images from each side by 1-16px, do not resize the results
    #     images back to the input size. Keep them at the cropped size.
    # (2) Horizontally flip 50% of the images.
    # (3) Blur images using a gaussian kernel with sigma between 0.0 and 3.0.
    seq = iaa.Sequential([
        iaa.Crop(px=(1, 16), keep_size=False),
        iaa.Fliplr(0.5),
        iaa.GaussianBlur(sigma=(0, 3.0))
    ])

    for batch_idx in range(100):
        images = load_batch(batch_idx)
        images_aug = seq(images=images)  # done by the library
        train_on_images(images_aug)

        # -----
        # Make sure that the example really does something
        if batch_idx == 0:
            assert not np.array_equal(images, images_aug) 
开发者ID:aleju,项目名称:imgaug,代码行数:41,代码来源:check_readme_examples.py


注:本文中的imgaug.augmenters.Fliplr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。