예제 #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
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)
plot_grid(ims, savepath + 'crops.png')

############################################
# CROPS
tic = time()
resized_im = imresize(cropped_im, (256, 256))
ims = [cropped_im] + [aug.random_crop(resized_im) for _ in range(24)]
print "Alexnet cropping took %fs per image" % ((time()-tic)/24.0)
plot_grid(ims, savepath + 'alexnet_crops.png')

############################################
# FLIPS
tic = time()
ims = [cropped_im] + [aug.random_flip(cropped_im) for _ in range(24)]
print "Flipping took %fs per image" % ((time()-tic)/24.0)
plot_grid(ims, savepath + 'flips.png')

############################################
# ALL
tic = time()
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))

ims = [cropped_im] + [full_trans(im) for _ in range(24)]
print "Full transform took %fs per image" % ((time()-tic)/24.0)