def augment(
rotation_fn=lambda: np.random.random_integers(0, 360),
translation_fn=lambda: (np.random.random_integers(-20, 20), np.random.random_integers(-20, 20)),
scale_factor_fn=random_zoom_range(),
shear_fn=lambda: np.random.random_integers(-10, 10)
):
def call(x):
rotation = rotation_fn()
translation = translation_fn()
scale = scale_factor_fn()
shear = shear_fn()
tf_augment = AffineTransform(scale=scale, rotation=np.deg2rad(rotation), translation=translation, shear=np.deg2rad(shear))
tf = tf_center + tf_augment + tf_uncenter
x = warp(x, tf, order=1, preserve_range=True, mode='symmetric')
return x
return call
评论列表
文章目录