def test():
test_filename = sys.argv[2]
test_image = scipy.misc.imread(test_filename, flatten=True)
test_image = scipy.misc.imresize(test_image, [kanji_height, kanji_width])
test_image = skimage.img_as_float(test_image).astype(np.float32)
#test_image = 1.0 - test_image
#test_image /= np.linalg.norm(test_image)
#test_image = 1.0 - test_image
scipy.misc.imsave("test.png", test_image)
model.load("kanji.tflearn")
Y = model.predict(test_image.reshape([-1, kanji_height, kanji_width]))[0]
Y_indices = np.argsort(Y)[::-1]
num_test = 5
for i in range(num_test):
print("Kanji: " + str(Y_indices[i]) + ", score=" + str(Y[Y_indices[i]]))
评论列表
文章目录