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


Python augmenters.Augmenter方法代码示例

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


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

示例1: test_augment_images

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test_augment_images(self):
        class _DummyAugmenter(meta.Augmenter):
            def __init__(self):
                super(_DummyAugmenter, self).__init__()
                self.call_count = 0

            def _augment_batch_(self, batch, random_state, parents, hooks):
                assert batch.images[0].dtype.name == "int16"
                self.call_count += 1
                return batch

            def get_parameters(self):
                return []

        aug_dummy = _DummyAugmenter()
        aug = iaa.WithHueAndSaturation(aug_dummy)

        image = np.zeros((4, 4, 3), dtype=np.uint8)
        image_aug = aug.augment_images([image])[0]
        assert image_aug.dtype.name == "uint8"
        assert np.array_equal(image_aug, image)
        assert aug_dummy.call_count == 1 
开发者ID:aleju,项目名称:imgaug,代码行数:24,代码来源:test_color.py

示例2: test_augment_heatmaps

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test_augment_heatmaps(self):
        from imgaug.augmentables.heatmaps import HeatmapsOnImage

        class _DummyAugmenter(meta.Augmenter):
            def __init__(self):
                super(_DummyAugmenter, self).__init__()
                self.call_count = 0

            def _augment_batch_(self, batch, random_state, parents, hooks):
                self.call_count += 1
                return batch

            def get_parameters(self):
                return []

        aug_dummy = _DummyAugmenter()
        hm = np.ones((8, 12, 1), dtype=np.float32)
        hmoi = HeatmapsOnImage(hm, shape=(16, 24, 3))

        aug = iaa.WithHueAndSaturation(aug_dummy)
        hmoi_aug = aug.augment_heatmaps(hmoi)
        assert hmoi_aug.shape == (16, 24, 3)
        assert hmoi_aug.arr_0to1.shape == (8, 12, 1)

        assert aug_dummy.call_count == 1 
开发者ID:aleju,项目名称:imgaug,代码行数:27,代码来源:test_color.py

示例3: _init_augmenter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def _init_augmenter(self, augmenter):
        if isinstance(augmenter, type(None)):
            self.augmenter = augmenter
        elif isinstance(augmenter, iaa.Augmenter):
            self.augmenter = augmenter
        elif isinstance(augmenter, list):
            if isinstance(augmenter[0], iaa.Augmenter):
                self.augmenter = iaa.Sequential(augmenter)
            else:
                raise TypeError(
                    """`augmenter` must be class Augmenter
                            (imgaug.augmenters.Augmenter)
                            or list of Augmenters"""
                )
        else:
            raise ValueError(
                """augmenter must be class
                             Augmenter, list of Augmenters, or None"""
            ) 
开发者ID:jgraving,项目名称:DeepPoseKit,代码行数:21,代码来源:TrainingGenerator.py

示例4: test___init___defaults

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test___init___defaults(self):
        aug = iaa.WithBrightnessChannels()
        assert isinstance(aug.children, iaa.Augmenter)
        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,代码行数:9,代码来源:test_color.py

示例5: test___init___to_colorspace_is_all

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test___init___to_colorspace_is_all(self):
        aug = iaa.WithBrightnessChannels(to_colorspace=ia.ALL)
        assert isinstance(aug.children, iaa.Augmenter)
        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,代码行数:9,代码来源:test_color.py

示例6: test___init___to_colorspace_is_cspace

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test___init___to_colorspace_is_cspace(self):
        aug = iaa.WithBrightnessChannels(to_colorspace=iaa.CSPACE_YUV)
        assert isinstance(aug.children, iaa.Augmenter)
        assert aug.to_colorspace.value == iaa.CSPACE_YUV
        assert aug.from_colorspace == iaa.CSPACE_RGB 
开发者ID:aleju,项目名称:imgaug,代码行数:7,代码来源:test_color.py

示例7: test___init___to_colorspace_is_stochastic_parameter

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test___init___to_colorspace_is_stochastic_parameter(self):
        aug = iaa.WithBrightnessChannels(
            to_colorspace=iap.Deterministic(iaa.CSPACE_YUV))
        assert isinstance(aug.children, iaa.Augmenter)
        assert aug.to_colorspace.value == iaa.CSPACE_YUV
        assert aug.from_colorspace == iaa.CSPACE_RGB 
开发者ID:aleju,项目名称:imgaug,代码行数:8,代码来源:test_color.py

示例8: test_augment_keypoints

# 需要导入模块: from imgaug import augmenters [as 别名]
# 或者: from imgaug.augmenters import Augmenter [as 别名]
def test_augment_keypoints(self):
        from imgaug.augmentables.kps import KeypointsOnImage

        class _DummyAugmenter(meta.Augmenter):
            def __init__(self):
                super(_DummyAugmenter, self).__init__()
                self.call_count = 0

            def _augment_batch_(self, batch, random_state, parents, hooks):
                self.call_count += 1
                return batch

            def get_parameters(self):
                return []

        aug_dummy = _DummyAugmenter()
        kpsoi = KeypointsOnImage.from_xy_array(np.float32([
            [0, 0],
            [5, 1]
        ]), shape=(16, 24, 3))

        aug = iaa.WithHueAndSaturation(aug_dummy)
        kpsoi_aug = aug.augment_keypoints(kpsoi)
        assert kpsoi_aug.shape == (16, 24, 3)
        assert kpsoi.keypoints[0].x == 0
        assert kpsoi.keypoints[0].y == 0
        assert kpsoi.keypoints[1].x == 5
        assert kpsoi.keypoints[1].y == 1

        assert aug_dummy.call_count == 1 
开发者ID:aleju,项目名称:imgaug,代码行数:32,代码来源:test_color.py


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