data.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:tefla 作者: openAGI 项目源码 文件源码
def perturb_fixed(img, tform_augment, target_shape=(50, 50), mode='constant', mode_cval=0):
    """Perturb image Determinastic

    It perturbs an image with augmentation transform with determinastic params
    used for validation/testing data

    Args:
        img: a `ndarray`, input image
        augmentation_paras: a dict, with augmentation name as keys and values as params
        target_shape: a tuple(rows, cols), output image shape
        mode: mode for transformation
            available modes: {`constant`, `edge`, `symmetric`, `reflect`, `wrap`}
        mode_cval: float, Used in conjunction with mode `constant`,
            the value outside the image boundaries

    Returns:
        a `ndarray` of transformed image
    """
    shape = img.shape[1:]
    tform_centering = build_centering_transform(shape, target_shape)
    tform_center, tform_uncenter = build_center_uncenter_transforms(shape)
    # shift to center, augment, shift back (for the rotation/shearing)
    tform_augment = tform_uncenter + tform_augment + tform_center
    return fast_warp(img, tform_centering + tform_augment,
                     output_shape=target_shape, mode=mode, mode_cval=mode_cval)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号