我正在尝试使用我自己的数字图像数据集来测试 mnist。
我为此编写了一个 python 脚本,但它给出了一个错误。错误出现在代码的第 16 行。实际上我无法发送图像进行测试。给我一些建议。提前致谢。
import numpy as np
import sys
import caffe
import matplotlib.pyplot as plt
import os
caffe_root = '../caffe-master/'
MODEL_FILE = './examples/mnist/lenet.prototxt'
PRETRAINED = './examples/mnist/lenet_iter_10000.caffemodel'
IMAGE_FILE = '/home/hemant/OpenCVProject/grey/img001-00001.png'#image path
input_image = caffe.io.load_image(IMAGE_FILE)
net = caffe.Net(MODEL_FILE, PRETRAINED,caffe.TEST)
caffe.set_mode_cpu()
out = net.forward([input_image])
print out['prob']
最佳答案
为什么不使用Python包装类Classifier
?
net = caffe.Classifier( MODEL_FILE, PRETRAINED )
net.predict( [input_image], oversmaple=False )
我不是 100% 确定,但我认为 LeNeT 模型需要灰度图像,您可能需要读取图像
input_image = caffe.io.load_image(IMAGE_FILE, color=False)
关于python - 如何在我自己的数据集图像上测试 mnist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29658790/