caffe 06 win10 运行examples的imagenet测试用例

来源:互联网 发布:淘宝店铺有几个橱窗 编辑:程序博客网 时间:2024/03/28 17:15

01 资料

caffe官网Examples中有关于ImageNet测试的详细介绍。
http://caffe.berkeleyvision.org/gathered/examples/imagenet.html
caffe github下载的代码中有关于ImageNet的网络定义示例和下载数据sh文件。

目录 文件类型 文件作用 data\ilsvrc12 get_ilsvrc_aux.sh 下载已经训练好的数据 examples\imagenet readme.md 实验说明文件 examples\imagenet *.sh 训练数据linux shell脚本 examples\cpp_classification classification.cpp 分类工具源码 examples\cpp_classification readme.md 测试说明 models\bvlc_reference_caffenet readme.md bvlc_reference_caffenet模型说明 examples\images cat.jpg 检测的分类图片

examples\cpp_classification\readme.md里详细说明了classification工具的用法。

02 测试操作步骤

02.01 下载测试数据

根据examples\imagenet\readme.md文档说明,imagenet的数据量太大。这里不下载原始image数据,不自己进行分类训练,只下载以训练好的数据,做一个图片的分类测试。
根据 data\ilsvrc12\get_ilsvrc_aux.sh 文件下载caffe_ilsvrc12.tar.gz并解压到data\ilsvrc12\caffe_ilsvrc12。

#!/usr/bin/env sh## N.B. This does not download the ilsvrcC12 data set, as it is gargantuan.# This script downloads the imagenet example auxiliary files including:# - the ilsvrc12 image mean, binaryproto# - synset ids and words# - Python pickle-format data of ImageNet graph structure and relative infogain# - the training splits with labelsDIR="$( cd "$(dirname "$0")" ; pwd -P )"cd "$DIR"echo "Downloading..."wget -c http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gzecho "Unzipping..."tar -xf caffe_ilsvrc12.tar.gz && rm -f caffe_ilsvrc12.tar.gzecho "Done."

data\ilsvrc12\caffe_ilsvrc12内容如下:

因为原始数据量太大,不做数据原始image数据获取和模型生成。跳过create_imagenet.sh和make_imagenet_mean.sh

#跳过这两步examples/imagenet/create_imagenet.shexamples/imagenet/make_imagenet_mean.sh

根据models\bvlc_reference_caffenet\readme.md说明,从http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel下载bvlc_reference_caffenet.caffemodel模型,保存在models\bvlc_reference_caffenet\bvlc_reference_caffenet.caffemodel

02.02 运行classification分类测试

根据examples\cpp_classification\readme.md文件说明。
在caffe根目录(D:\git\DeepLearning\caffe)运行:

build\x64\install\bin\classification.exe models\bvlc_reference_caffenet\deploy.prototxt models\bvlc_reference_caffenet\bvlc_reference_caffenet.caffemodel data\ilsvrc12\caffe_ilsvrc12\imagenet_mean.binaryproto data\ilsvrc12\caffe_ilsvrc12\synset_words.txt examples\images\cat.jpg

运行结果如下:

---------- Prediction for examples\images\cat.jpg ----------0.3134 - "n02123045 tabby, tabby cat"0.2380 - "n02123159 tiger cat"0.1235 - "n02124075 Egyptian cat"0.1003 - "n02119022 red fox, Vulpes vulpes"0.0715 - "n02127052 lynx, catamount"
0 0