【发布时间】:2017-02-18 20:39:57
【问题描述】:
我正在使用 Caffe (http://caffe.berkeleyvision.org/) 进行图像分类。我在 Windows 上使用它,一切似乎都编译得很好。
为了开始学习,我遵循了 MNIST 教程 (http://caffe.berkeleyvision.org/gathered/examples/mnist.html)。我下载了数据并运行了 ..\caffe.exe train --solver=...examples\mnist\lenet_solver.prototxt。它运行了 10.000 次迭代,打印出准确度为 98.5,并生成了两个文件:lenet_iter_10000.solverstate 和 lenet_iter_10000.caffemodel。
所以,虽然尝试对自己的图像进行分类会很有趣,但应该很容易吧?
我可以找到以下资源:https://software.intel.com/en-us/articles/training-and-deploying-deep-learning-networks-with-caffe-optimized-for-intel-architecture#Examples 告诉我如何准备、训练和计时我的模型。但是每次教程/文章实际上将单个实例放入 CNN 时,他们都会跳到下一点并告诉下载一些新模型。一些资源告诉使用分类器.bin/.exe,但这个文件需要一个 imagenet_mean.binaryproto 或类似的 mnist。我不知道在哪里可以找到或生成此文件。
简而言之:当我使用 Caffe 训练 CNN 时,如何输入单个图像并使用我已有的文件获取输出?
更新:根据帮助,我让网络识别图像,但即使网络的准确率为 99.0%,识别也不正确。我使用以下 python 代码来识别图像:
NET_FILE = 'deploy.prototxt'
MODEL_FILE = 'lenet_iter_10000.caffemodel'
net = caffe.Net(NET_FILE, MODEL_FILE, caffe.TEST)
im = Image.open("img4.jpg")
in_ = np.array(im, dtype=np.float32)
net.blobs['data'].data[...] = in_
out = net.forward() # Run the network for the given input image
print out;
我不确定我是否为 MNIST 示例正确格式化了图像。图片是28x28灰度图片,基础4。我需要对图片做更多的变换吗?
网络(部署)如下所示(开始和结束):
input: "data"
input_shape {
dim: 1 # batchsize
dim: 1 # number of colour channels - rgb
dim: 28 # width
dim: 28 # height
}
....
layer {
name: "loss"
type: "Softmax"
bottom: "ip2"
top: "loss"
}
【问题讨论】:
标签: neural-network caffe convolution pycaffe