train_cycle_gan.py 文件源码

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

项目:chainer-image-generation 作者: fukuta0614 项目源码 文件源码
def random_augmentation(image, crop_size, resize_size):
    # randomly choose crop size
    image = image.transpose(1, 2, 0)
    h, w, _ = image.shape

    # random cropping
    if crop_size != h:
        top = random.randint(0, h - crop_size - 1)
        left = random.randint(0, w - crop_size - 1)
        bottom = top + crop_size
        right = left + crop_size
        image = image[top:bottom, left:right, :]

    # random flipping
    if random.randint(0, 1):
        image = image[:, ::-1, :]

    # randomly choose resize size
    if resize_size != crop_size:
        cv2.resize(image, (resize_size, resize_size), interpolation=cv2.INTER_AREA)

    return image.transpose(2, 0, 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号