本文整理汇总了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
示例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
示例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"""
)
示例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
示例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
示例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
示例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
示例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