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


Python augmenters.Scale方法代码示例

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


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

示例1: chapter_augmenters_scale

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def chapter_augmenters_scale():
    aug = iaa.Scale({"height": 32, "width": 64})
    run_and_save_augseq(
        "scale_32x64.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    )

    aug = iaa.Scale({"height": 32, "width": "keep-aspect-ratio"})
    run_and_save_augseq(
        "scale_32xkar.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    )

    aug = iaa.Scale((0.5, 1.0))
    run_and_save_augseq(
        "scale_50_to_100_percent.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    )

    aug = iaa.Scale({"height": (0.5, 0.75), "width": [16, 32, 64]})
    run_and_save_augseq(
        "scale_h_uniform_w_choice.jpg", aug,
        [ia.quokka(size=(128, 128)) for _ in range(8)], cols=4, rows=2
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:26,代码来源:generate_documentation_images.py

示例2: resize_seq

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def resize_seq(resize_target_size):
    seq = iaa.Sequential([
        affine_seq,
        iaa.Scale({'height': resize_target_size, 'width': resize_target_size}),
    ], random_order=False)
    return seq 
开发者ID:neptune-ai,项目名称:open-solution-salt-identification,代码行数:8,代码来源:augmentation.py

示例3: resize_pad_seq

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def resize_pad_seq(resize_target_size, pad_method, pad_size):
    seq = iaa.Sequential([
        affine_seq,
        iaa.Scale({'height': resize_target_size, 'width': resize_target_size}),
        PadFixed(pad=(pad_size, pad_size), pad_method=pad_method),
    ], random_order=False)
    return seq 
开发者ID:neptune-ai,项目名称:open-solution-salt-identification,代码行数:9,代码来源:augmentation.py

示例4: resize_to_fit_net

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def resize_to_fit_net(resize_target_size):
    seq = iaa.Sequential(iaa.Scale({'height': resize_target_size, 'width': resize_target_size}))
    return seq 
开发者ID:neptune-ai,项目名称:open-solution-salt-identification,代码行数:5,代码来源:augmentation.py

示例5: augment_soft

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def augment_soft(img):
    # Sometimes(0.5, ...) applies the given augmenter in 50% of all cases,
    # e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second image.
    sometimes = lambda aug: iaa.Sometimes(0.5, aug)

    # Define our sequence of augmentation steps that will be applied to every image
    # All augmenters with per_channel=0.5 will sample one value _per image_
    # in 50% of all cases. In all other cases they will sample new values
    # _per channel_.
    seq = iaa.Sequential(
        [
            # apply the following augmenters to most images
            iaa.Fliplr(0.5), # horizontally flip 50% of all images
            # crop images by -5% to 10% of their height/width
            iaa.Crop(
                percent=(0, 0.2),
            ),
            iaa.Scale({"height": CROP_SIZE, "width": CROP_SIZE }),
        ],
        random_order=False
    )

    if img.ndim == 3:
        img = seq.augment_images(np.expand_dims(img, axis=0)).squeeze(axis=0)
    else:
        img = seq.augment_images(img)

    return img 
开发者ID:antorsae,项目名称:landmark-recognition-challenge,代码行数:30,代码来源:train.py

示例6: __init__

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def __init__(self):
        self.augmentor_pipeline = Pipeline()
        self.augmentor_pipeline.add_operation(Operations.Crop(probability=1, width=64, height=64, centre=False))
        self.augmentor_pipeline.add_operation(
            Operations.Resize(probability=1, width=512, height=512, resample_filter="BILINEAR")
        )
        self.imgaug_transform = iaa.Sequential(
            [iaa.CropToFixedSize(width=64, height=64), iaa.Scale(size=512, interpolation="linear")]
        )
        self.solt_stream = slc.Stream(
            [slt.CropTransform(crop_size=(64, 64), crop_mode="r"), slt.ResizeTransform(resize_to=(512, 512))]
        ) 
开发者ID:albumentations-team,项目名称:albumentations,代码行数:14,代码来源:benchmark.py

示例7: chapter_examples_basics_simple

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Scale [as 别名]
def chapter_examples_basics_simple():
    import imgaug as ia
    from imgaug import augmenters as iaa

    # Example batch of images.
    # The array has shape (32, 64, 64, 3) and dtype uint8.
    images = np.array(
        [ia.quokka(size=(64, 64)) for _ in range(32)],
        dtype=np.uint8
    )

    seq = iaa.Sequential([
        iaa.Fliplr(0.5), # horizontal flips
        iaa.Crop(percent=(0, 0.1)), # random crops
        # Small gaussian blur with random sigma between 0 and 0.5.
        # But we only blur about 50% of all images.
        iaa.Sometimes(0.5,
            iaa.GaussianBlur(sigma=(0, 0.5))
        ),
        # Strengthen or weaken the contrast in each image.
        iaa.ContrastNormalization((0.75, 1.5)),
        # Add gaussian noise.
        # For 50% of all images, we sample the noise once per pixel.
        # For the other 50% of all images, we sample the noise per pixel AND
        # channel. This can change the color (not only brightness) of the
        # pixels.
        iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5),
        # Make some images brighter and some darker.
        # In 20% of all cases, we sample the multiplier once per channel,
        # which can end up changing the color of the images.
        iaa.Multiply((0.8, 1.2), per_channel=0.2),
        # Apply affine transformations to each image.
        # Scale/zoom them, translate/move them, rotate them and shear them.
        iaa.Affine(
            scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
            translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)},
            rotate=(-25, 25),
            shear=(-8, 8)
        )
    ], random_order=True) # apply augmenters in random order

    ia.seed(1)
    images_aug = seq.augment_images(images)

    # ------------

    save(
        "examples_basics",
        "simple.jpg",
        grid(images_aug, cols=8, rows=4)
    ) 
开发者ID:JoshuaPiinRueyPan,项目名称:ViolenceDetection,代码行数:53,代码来源:generate_documentation_images.py


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