def testClassifier():
clf = pickle.load(open("classifier.p", "rb"))
classes = numpy.loadtxt(dataset_root + 'classes.txt', dtype=str)
classes = column(classes, 0)
image_files = sorted(listdir(
join(project_root, test_images_dir)))
for image in image_files:
features = extractFeatures(
str(abspath(join(project_root, test_images_dir, image))))
prediction = clf.predict(features)
img = mpimg.imread(
str(abspath(join(project_root, test_images_dir, image))))
fig = plt.figure()
fig.suptitle(classes[int(prediction[0])],
fontsize=14, fontweight='bold')
plt.imshow(img)
评论列表
文章目录