示例#1
0
def full_trans(im):
    rotated = aug.random_rotation(im, sd=10, **newcrop)
    cropped = aug.randn_crop(rotated, sd=10, **newcrop)
    flipped = aug.random_flip(cropped)
    coloured = aug.random_colour_transform(flipped, rgb_eigval, rgb_eigvec)
    return imresize(coloured, (256, 256))
示例#2
0
rots = [aug.randn_crop(im, sd=0, **newcrop) for im in rots]
ims = [cropped_im] + rots
print "Rotating took %fs per image" % ((time()-tic)/24.0)
plot_grid(ims, savepath + 'rotations.png')

############################################
# COLOUR TRANSFORMS
rgb_vals = cropped_im.transpose((2, 0, 1)).reshape((3, -1))
rgb_eigval, rgb_eigvec = eig(np.cov(rgb_vals - rgb_vals.mean(1)[:, None]))
rgb_eigvec, rgb_eigval, v = np.linalg.svd(
    rgb_vals - rgb_vals.mean(1)[:, None], full_matrices=False)
rgb_eigval = np.real(rgb_eigval)
rgb_eigval /= rgb_eigval.sum()

tic = time()
ims = [cropped_im] + [aug.random_colour_transform(
    cropped_im, rgb_eigval, rgb_eigvec) for _ in range(24)]
print "Colour transform took %fs per image" % ((time()-tic)/24.0)
plot_grid(ims, savepath + 'cols.png')

############################################
# NORMS
tic = time()
ims = [cropped_im for _ in range(25)]
print "No augmentation took %fs per image" % ((time()-tic)/24.0)
plot_grid(ims, savepath + 'norms.png')

############################################
# CROPS
tic = time()
ims = [cropped_im] + [aug.randn_crop(im, sd=10, **newcrop) for _ in range(24)]
print "Randn cropping took %fs per image" % ((time()-tic)/24.0)