700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 利用 caffe的 python接口测试训练好的 mnist 模型

利用 caffe的 python接口测试训练好的 mnist 模型

时间:2022-06-26 07:56:30

相关推荐

利用 caffe的 python接口测试训练好的 mnist 模型

参考博客:/auto1993/article/details/70941440

在上一篇博客中已经训练好了 mnist 识别手写数字的模型,这篇博客就利用 caffe 的 python 接口对得到的模型进行测试

from PIL import Imageimport matplotlib.pyplot as pltimport numpy as npimport caffefrom skimage import ioimgsource = 'F:/python_work/mnist/images/001.png'img = Image.open(imgsource)plt.figure("image")plt.imshow(img)plt.show()modefile = 'F:/caffe-master/examples/mnist/lenet.prototxt'pretrain = 'F:/caffe-master/examples/mnist/lenet_iter_10000.caffemodel'inputImage = caffe.io.load_image(imgsource,color=False)net = caffe.Classifier(modefile,pretrain)prediction = net.predict([inputImage],oversample=False)caffe.set_mode_gpu()print'predicted classes:',prediction[0].argmax()

运行结果

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。