本文整理汇总了Python中Augmentor.Pipeline方法的典型用法代码示例。如果您正苦于以下问题:Python Augmentor.Pipeline方法的具体用法?Python Augmentor.Pipeline怎么用?Python Augmentor.Pipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Augmentor
的用法示例。
在下文中一共展示了Augmentor.Pipeline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Augmentor [as 别名]
# 或者: from Augmentor import Pipeline [as 别名]
def __init__(self,
dataset_config=None,
additional_augmentor_obj=None
):
self.p = Augmentor.Pipeline()
if dataset_config is not None and 'pipeline' in dataset_config:
for pipeline in dataset_config['pipeline']:
method_to_call = getattr(self.p, pipeline[0])
parameters = pipeline[1]
method_to_call(**parameters)
if additional_augmentor_obj is not None:
for pipeline in additional_augmentor_obj:
method_to_call = getattr(self.p, pipeline[0])
parameters = pipeline[1]
method_to_call(**parameters)
self.transform = self.p.torch_transform()
if dataset_config is not None and 'scaling' in dataset_config:
self.scaling = dataset_config['scaling']
else:
self.scaling = 'tanh'
示例2: augment
# 需要导入模块: import Augmentor [as 别名]
# 或者: from Augmentor import Pipeline [as 别名]
def augment():
p = Augmentor.Pipeline(
source_directory=ORIGIN_MERGED_SOURCE_DIRECTORY,
output_directory=AUGMENT_OUTPUT_DIRECTORY
)
p.rotate(probability=0.2, max_left_rotation=2, max_right_rotation=2)
p.zoom(probability=0.2, min_factor=1.1, max_factor=1.2)
p.skew(probability=0.2)
p.random_distortion(probability=0.2, grid_width=100, grid_height=100, magnitude=1)
p.shear(probability=0.2, max_shear_left=2, max_shear_right=2)
p.crop_random(probability=0.2, percentage_area=0.8)
p.flip_random(probability=0.2)
p.sample(n=TRAIN_SET_SIZE + VALIDATION_SET_SIZE + TEST_SET_SIZE)
示例3: distort
# 需要导入模块: import Augmentor [as 别名]
# 或者: from Augmentor import Pipeline [as 别名]
def distort():
p = Augmentor.Pipeline()
p.random_distortion(probability=1, grid_width=5, grid_height=5, magnitude=8)
def call(x):
x = p.sample_with_array(x.astype('uint8'), False)
return x
return call
示例4: __init__
# 需要导入模块: import Augmentor [as 别名]
# 或者: from Augmentor import Pipeline [as 别名]
def __init__(self):
self.imgaug_transform = iaa.Sequential(
[iaa.Multiply((1.5, 1.5), per_channel=False), iaa.Add((127, 127), per_channel=False)]
)
self.augmentor_pipeline = Pipeline()
self.augmentor_pipeline.add_operation(
Operations.RandomBrightness(probability=1, min_factor=1.5, max_factor=1.5)
)
self.augmentor_pipeline.add_operation(Operations.RandomContrast(probability=1, min_factor=1.5, max_factor=1.5))
self.solt_stream = slc.Stream(
[
slt.ImageRandomBrightness(p=1, brightness_range=(127, 127)),
slt.ImageRandomContrast(p=1, contrast_range=(1.5, 1.5)),
]
)