def input_wrapper(f):
image = misc.imread(f)
sx,sy = image.shape
diff = np.abs(sx-sy)
sx,sy = image.shape
image = np.pad(image,((sx//8,sx//8),(sy//8,sy//8)),'constant')
if sx > sy:
image = np.pad(image,((0,0),(diff//2,diff//2)),'constant')
else:
image = np.pad(image,((diff//2,diff//2),(0,0)),'constant')
image = dilation(image,disk(max(sx,sy)/32))
image = misc.imresize(image,(32,32))
if np.max(image) > 1:
image = image/255.
return image
评论列表
文章目录