CaffeNet C++ Classification 例子运行方法
来源:互联网 发布:数字移相算法 编辑:程序博客网 时间:2024/06/13 23:35
/$CAFFE_ROOT/examples/cpp_classification/readme.md
https://github.com/BVLC/caffe/blob/master/examples/cpp_classification/classification.cpp
编译:
这个C++的例子是在编译Caffe的时候自动编译的。
这个分类的例子被编译成build/examples/classification.bin
用法:
为了使用已经提前训练好的用于分类案例的CaffeNet模型,首先需要下载“Model Zoo”,使用以下命令:
./scripts/download_model_binary.py models/bvlc_reference_caffenet可能灰遇到的问题是,在import yaml处报错。
安装yaml://yaml是什么
下载地址是 http://pyyaml.org/wiki/PyYAML
根据系统类型选择并下载,安装方法在页面下方。
安装好yaml之后运行命令,会在models/bvlc_reference_caffenet下下载文件 bvlc_reference_caffenet.caffemodle。
ImageNet的标签文件(也称为synset file,同义词集文件)也许要下载,用来对预测的类名做映射:
./data/ilsvrc12/get_ilsvrc_aux.shsh文件内容:
#!/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 $DIRecho "Downloading..."wget http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gzecho "Unzipping..."tar -xf caffe_ilsvrc12.tar.gz && rm -f caffe_ilsvrc12.tar.gzecho "Done."
caffe_ilsvrc12.tar.gz解压后包括一下几个文件:
det_synset_words.txt
imagenet_mean.binaryproto
test.txt
synsets.txt
train.txt
imagenet.bet.pickle
synset_words.txt
val.txt
Using the files that were downloaded, we can classify the provided cat
使用下载的文件,我们可以提供的小猫的图片进行分类,命令如下:
./build/examples/cpp_classification/classification.bin \ models/bvlc_reference_caffenet/deploy.prototxt \ models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel \ data/ilsvrc12/imagenet_mean.binaryproto \ data/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"
提高性能:
为了进一步提高性能,可以更多地利用GPU,以下是指南:
* Move the data on the GPU early and perform all preprocessing
operations there.
* If you have many images to classify simultaneously, you should use
batching (independent images are classified in a single forward pass).
* Use multiple classification threads to ensure the GPU is always fully
utilized and not waiting for an I/O blocked CPU thread.
c++ 参数说明
- CaffeNet C++ Classification 例子运行方法
- caffe利用caffenet运行bvlc_reference_caffenet.caffemodel时错误
- CaffeNet简介
- classification
- Classification
- classification
- Classification
- C语言argc和argv经典小例子如何运行
- c语言获取程序运行的时间例子
- 深度学习:Imagenet Object Classification方法
- SVM Classification python example using sklearn 分类例子
- 工厂模式-CaffeNet训练
- 工厂模式-CaffeNet训练
- C/C++/Qt软件系统统计运行时间方法详解
- listView中显示表格的方法例子(C#)
- UNP例子运行
- Jasperreport 报表例子运行
- jpetstore例子运行记录
- MongoDB Replica Sets + Sharding 方案 及 chunks块 和 片键分析
- 商务通通过JS获取sid、cid等参数
- oracle 数据更新讲解
- Java 多线程 并发编程
- MFC单文档视图之图标资源加载及绘制
- CaffeNet C++ Classification 例子运行方法
- WebSocket实例—初级聊天室(来自Tomcat8的examples)
- android监测用户刚刚拍照
- 关键词研究
- Hbase-1.1.2 Java API 操作
- duoj Almost sorted interval 单调队列
- [Java]剑走偏锋的10条编程技巧
- C语言实现大整数乘法代码的完整代码及运行结果
- 图片下面加字排版