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


Python augmenters.Multiply方法代码示例

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


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

示例1: _load_augmentation_aug_non_geometric

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def _load_augmentation_aug_non_geometric():
    return iaa.Sequential([
        iaa.Sometimes(0.3, iaa.Multiply((0.5, 1.5), per_channel=0.5)),
        iaa.Sometimes(0.2, iaa.JpegCompression(compression=(70, 99))),
        iaa.Sometimes(0.2, iaa.GaussianBlur(sigma=(0, 3.0))),
        iaa.Sometimes(0.2, iaa.MotionBlur(k=15, angle=[-45, 45])),
        iaa.Sometimes(0.2, iaa.MultiplyHue((0.5, 1.5))),
        iaa.Sometimes(0.2, iaa.MultiplySaturation((0.5, 1.5))),
        iaa.Sometimes(0.34, iaa.MultiplyHueAndSaturation((0.5, 1.5),
                                                         per_channel=True)),
        iaa.Sometimes(0.34, iaa.Grayscale(alpha=(0.0, 1.0))),
        iaa.Sometimes(0.2, iaa.ChangeColorTemperature((1100, 10000))),
        iaa.Sometimes(0.1, iaa.GammaContrast((0.5, 2.0))),
        iaa.Sometimes(0.2, iaa.SigmoidContrast(gain=(3, 10),
                                               cutoff=(0.4, 0.6))),
        iaa.Sometimes(0.1, iaa.CLAHE()),
        iaa.Sometimes(0.1, iaa.HistogramEqualization()),
        iaa.Sometimes(0.2, iaa.LinearContrast((0.5, 2.0), per_channel=0.5)),
        iaa.Sometimes(0.1, iaa.Emboss(alpha=(0, 1.0), strength=(0, 2.0)))
    ]) 
开发者ID:divamgupta,项目名称:image-segmentation-keras,代码行数:22,代码来源:augmentation.py

示例2: test_single_image

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_single_image(self):
        image = np.full((10, 10, 3), 255, dtype=np.uint8)
        bbs = [ia.BoundingBox(x1=1, y1=1, x2=5, y2=5, label="bb1"),
               ia.BoundingBox(x1=-3, y1=4, x2=20, y2=8, label="bb2")]

        aug = iaa.BlendAlphaBoundingBoxes(
            ["bb1"],
            nb_sample_labels=1,
            foreground=iaa.Multiply(0.0)
        )

        image_aug, segmap_aug = aug(image=image,
                                    bounding_boxes=[bbs])

        assert np.allclose(image_aug[1:5, 1:5, :], 0, rtol=0, atol=1.01)
        assert np.allclose(image_aug[0:1, 0:1, :], 255, rtol=0, atol=1.01)
        assert np.allclose(image_aug[5:10, 5:10, :], 255, rtol=0, atol=1.01) 
开发者ID:aleju,项目名称:imgaug,代码行数:19,代码来源:test_blend.py

示例3: test_zero_sized_axes

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_zero_sized_axes(self):
        shapes = [
            (0, 0),
            (0, 1),
            (1, 0),
            (0, 1, 0),
            (1, 0, 0),
            (0, 1, 1),
            (1, 0, 1)
        ]

        for shape in shapes:
            with self.subTest(shape=shape):
                image = np.full(shape, 255, dtype=np.uint8)
                bbs = [ia.BoundingBox(x1=1, y1=1, x2=5, y2=5, label="bb1"),
                       ia.BoundingBox(x1=-3, y1=4, x2=20, y2=8, label="bb2")]
                aug = iaa.BlendAlphaBoundingBoxes(
                    ["bb1"],
                    foreground=iaa.Multiply(0.0))

                image_aug, segmap_aug = aug(
                    image=image, bounding_boxes=[bbs])

                assert image_aug.dtype.name == "uint8"
                assert image_aug.shape == shape 
开发者ID:aleju,项目名称:imgaug,代码行数:27,代码来源:test_blend.py

示例4: test_returns_correct_objects__mul_hue_and_mul_saturation

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_returns_correct_objects__mul_hue_and_mul_saturation(self):
        aug = iaa.MultiplyHueAndSaturation(mul_hue=(0.9, 1.1),
                                           mul_saturation=(0.8, 1.2))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 2

        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [0]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1)

        assert isinstance(aug.children[1], iaa.WithChannels)
        assert aug.children[1].channels == [1]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[1].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[1].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[1].children[0].mul.a.value, 0.8)
        assert np.isclose(aug.children[1].children[0].mul.b.value, 1.2) 
开发者ID:aleju,项目名称:imgaug,代码行数:26,代码来源:test_color.py

示例5: test_returns_correct_class

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_returns_correct_class(self):
        # this test is practically identical to
        # TestMultiplyToHueAndSaturation
        #     .test_returns_correct_objects__mul_saturation
        aug = iaa.MultiplySaturation((0.9, 1.1))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [1]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1) 
开发者ID:aleju,项目名称:imgaug,代码行数:18,代码来源:test_color.py

示例6: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def __init__(self):
        self.seq = iaa.Sequential([
            iaa.Sometimes(0.5, iaa.OneOf([
                iaa.GaussianBlur((0, 3.0)),  # blur images with a sigma between 0 and 3.0
                iaa.AverageBlur(k=(2, 7)),  # blur image using local means with kernel sizes between 2 and 7
                iaa.MedianBlur(k=(3, 11)),  # blur image using local medians with kernel sizes between 2 and 7
            ])),
            iaa.Sometimes(0.5, iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05 * 255), per_channel=0.5)),
            iaa.Sometimes(0.5, iaa.Add((-10, 10), per_channel=0.5)),
            iaa.Sometimes(0.5, iaa.AddToHueAndSaturation((-20, 20))),
            iaa.Sometimes(0.5, iaa.FrequencyNoiseAlpha(
                exponent=(-4, 0),
                first=iaa.Multiply((0.5, 1.5), per_channel=True),
                second=iaa.LinearContrast((0.5, 2.0))
            )),
            iaa.Sometimes(0.5, iaa.PiecewiseAffine(scale=(0.01, 0.05))),
            iaa.Sometimes(0.5, iaa.PerspectiveTransform(scale=(0.01, 0.1)))
        ], random_order=True) 
开发者ID:WenmuZhou,项目名称:crnn.gluon,代码行数:20,代码来源:augment.py

示例7: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [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

示例8: augment

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def augment(image, bbox):
    x = random.randint(-50, 50)
    y = random.randint(-50, 50)
    aug = iaa.Sequential([iaa.Multiply(random.uniform(0.5, 1.5)),
                          iaa.AdditiveGaussianNoise(random.uniform(0.01, 0.1) * 255),
                          iaa.Affine(translate_px={"x": x, "y": y},
                                     scale=random.uniform(0.5, 1.5),
                                     rotate=random.uniform(-45, 45),
                                     cval=(0, 255))])

    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)
    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,代码行数:26,代码来源:augmentation.py

示例9: augment

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def augment(image, bbox):
    x = random.randint(-60, 60)
    y = random.randint(-60, 60)
    aug = iaa.Sequential([iaa.AdditiveGaussianNoise(scale=random.uniform(.001, .01) * 255),  # gaussian noise
                          iaa.Multiply(random.uniform(0.5, 1.5)),  # brightness
                          iaa.Affine(translate_px={"x": x, "y": y},  # translation
                                     scale=random.uniform(0.5, 1.5),  # zoom in and out
                                     rotate=random.uniform(-25, 25),  # rotation
                                     shear=random.uniform(-5, 5),  # shear transformation
                                     cval=(0, 255))])  # fill the empty space with color

    aug.add(iaa.Salt(.001))
    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)
    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,代码行数:27,代码来源:augmentation.py

示例10: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def __init__(self,data_dir, back_dir,
                 batch_size=50,gan=True,imsize=128,
                 res_x=640,res_y=480,
                 **kwargs):
        '''
        data_dir: Folder that contains cropped image+xyz
        back_dir: Folder that contains random background images
            batch_size: batch size for training
        gan: if False, gt for GAN is not yielded
        '''
        self.data_dir = data_dir
        self.back_dir = back_dir
        self.imsize=imsize
        self.batch_size = batch_size
        self.gan = gan
        self.backfiles = os.listdir(back_dir)
        data_list = os.listdir(data_dir)
        self.datafiles=[]
        self.res_x=res_x
        self.res_y=res_y

        for file in data_list:
            if(file.endswith(".npy")):
                self.datafiles.append(file)

        self.n_data = len(self.datafiles)
        self.n_background = len(self.backfiles)
        print("Total training views:", self.n_data)

        self.seq_syn= iaa.Sequential([
                                    iaa.WithChannels(0, iaa.Add((-15, 15))),
                                    iaa.WithChannels(1, iaa.Add((-15, 15))),
                                    iaa.WithChannels(2, iaa.Add((-15, 15))),
                                    iaa.ContrastNormalization((0.8, 1.3)),
                                    iaa.Multiply((0.8, 1.2),per_channel=0.5),
                                    iaa.GaussianBlur(sigma=(0.0, 0.5)),
                                    iaa.Sometimes(0.1, iaa.AdditiveGaussianNoise(scale=10, per_channel=True)),
                                    iaa.Sometimes(0.5, iaa.ContrastNormalization((0.5, 2.2), per_channel=0.3)),
                                    ], random_order=True) 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:41,代码来源:data_io.py

示例11: mask_to_rle

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def mask_to_rle(image_id, mask, scores):
    "Encodes instance masks to submission format."
    assert mask.ndim == 3, "Mask must be [H, W, count]"
    # If mask is empty, return line with image ID only
    if mask.shape[-1] == 0:
        return "{},".format(image_id)
    # Remove mask overlaps
    # Multiply each instance mask by its score order
    # then take the maximum across the last dimension
    order = np.argsort(scores)[::-1] + 1  # 1-based descending
    mask = np.max(mask * np.reshape(order, [1, 1, -1]), -1)
    # Loop over instance masks
    lines = []
    for o in order:
        m = np.where(mask == o, 1, 0)
        # Skip if empty
        if m.sum() == 0.0:
            continue
        rle = rle_encode(m)
        lines.append("{}, {}".format(image_id, rle))
    return "\n".join(lines)


############################################################
#  Detection
############################################################ 
开发者ID:dmechea,项目名称:PanopticSegmentation,代码行数:28,代码来源:nucleus.py

示例12: test___init___defaults

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test___init___defaults(self):
        aug = iaa.MultiplyBrightness()
        assert isinstance(aug.children, iaa.Augmenter)
        assert isinstance(aug.children[0], iaa.Multiply)
        assert len(aug.to_colorspace.a) == len(self.valid_colorspaces)
        for cspace in self.valid_colorspaces:
            assert cspace in aug.to_colorspace.a
        assert aug.from_colorspace == iaa.CSPACE_RGB 
开发者ID:aleju,项目名称:imgaug,代码行数:10,代码来源:test_color.py

示例13: test___init___add_is_zero

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test___init___add_is_zero(self):
        aug = iaa.MultiplyAndAddToBrightness(add=0)
        assert aug.children.random_order is True
        assert isinstance(aug.children[0], iaa.Multiply)
        assert isinstance(aug.children[1], iaa.Identity)
        assert iaa.CSPACE_HSV in aug.to_colorspace.a
        assert aug.from_colorspace == iaa.CSPACE_RGB 
开发者ID:aleju,项目名称:imgaug,代码行数:9,代码来源:test_color.py

示例14: test_returns_correct_objects__mul

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_returns_correct_objects__mul(self):
        aug = iaa.MultiplyHueAndSaturation(
            (0.9, 1.1), per_channel=True)
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].mul, iap.Uniform)
        assert np.isclose(aug.children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].mul.b.value, 1.1)
        assert is_parameter_instance(aug.children[0].per_channel,
                                     iap.Deterministic)
        assert aug.children[0].per_channel.value == 1 
开发者ID:aleju,项目名称:imgaug,代码行数:15,代码来源:test_color.py

示例15: test_returns_correct_objects__mul_hue

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Multiply [as 别名]
def test_returns_correct_objects__mul_hue(self):
        aug = iaa.MultiplyHueAndSaturation(mul_hue=(0.9, 1.1))
        assert isinstance(aug, iaa.WithHueAndSaturation)
        assert isinstance(aug.children, iaa.Sequential)
        assert len(aug.children) == 1
        assert isinstance(aug.children[0], iaa.WithChannels)
        assert aug.children[0].channels == [0]
        assert len(aug.children[0].children) == 1
        assert isinstance(aug.children[0].children[0], iaa.Multiply)
        assert is_parameter_instance(aug.children[0].children[0].mul,
                                     iap.Uniform)
        assert np.isclose(aug.children[0].children[0].mul.a.value, 0.9)
        assert np.isclose(aug.children[0].children[0].mul.b.value, 1.1) 
开发者ID:aleju,项目名称:imgaug,代码行数:15,代码来源:test_color.py


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