augment.py 文件源码

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

项目:kaggle_dsb 作者: syagev 项目源码 文件源码
def testtime_augmentation(image, label):
    labels = []
    images = []
    rotations = [0]
    flips = [[0,0],[1,0],[0,1],[1,1]]
    shifts = [[0,0]]
    zooms = [1]

    for r in rotations:
        for f in flips:
            for s in shifts:
                for z in zooms:
                    image2 = np.array(image)
                    if f[0]:
                        image2[:,:] = image2[::-1,:]
                    if f[1]:
                        image2 = image2.transpose(1,0)
                        image2[:,:] = image2[::-1,:]
                        image2 = image2.transpose(1,0)
                    #rotate(image2, r, reshape=False, output=image2)
                    #image3 = zoom(image2, [z,z])
                    #image3 = crop_or_pad(image3, P.INPUT_SIZE, 0)
                    #image2 = image3
                    # #shift(image2, [s[0],s[1]], output=image2)
                    images.append([image2]) #Adds color channel dimension!
                    labels.append(label)

    return images, labels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号