c++调用vgg16:

./build/install/bin/classification    \
/media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt \
/media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel \
data/ilsvrc12/imagenet_mean.binaryproto \
/media/whale/wsWin10/wsCaffe/model-zoo/VGG16/synset_words.txt \
/media/whale/wsWin10/images/person/2.jpg

然后就报错了。

然后

whale@sea:/media/whale/wsWin10/wsUbuntu16./DlFrames/caffe$ ./build/install/bin/classification     /media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt    /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel    data/ilsvrc12/imagenet_mean.binaryproto    ./3labels.txt    /media/whale/wsWin10/images/person/2.jpg
labels_.size() = output_layer->channels() = ---------- Prediction for /media/whale/wsWin10/images/person/.jpg ----------
0.3333 - ""
0.3333 - ""
0.3333 - ""
whale@sea:/media/whale/wsWin10/wsUbuntu16./DlFrames/caffe$ ./build/install/bin/classification /media/whale/wsWin10/wsCaffe/model-zoo/VGG16//deploy.prototxt /media/whale/wsWin10/wsCaffe/model-zoo/VGG16/VGG_ILSVRC_16_layers.caffemodel data/ilsvrc12/imagenet_mean.binaryproto ./3labels.txt /media/whale/wsWin10/images/person/3.jpg
labels_.size() = output_layer->channels() = ---------- Prediction for /media/whale/wsWin10/images/person/.jpg ----------
0.3333 - ""
0.3333 - ""
0.3333 - ""

只能给3个标签,不然就报错。然后,。。。,这个模型是假的吗?

还是什么是假的?

keras-python调用vgg16:

python-keras接口调用模型要简单些,只需要标签文件,和keras模型就可以了。

from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input
from keras.models import Model
import numpy as np
import matplotlib.pyplot as plt
# get_ipython().magic(u'matplotlib inline') # ### 显示图像 # In[2]: img_path = './data/elephant.jpg'
img_path = '/media/whale/wsWin10/images/dog/0c02094a98d126cf541c4318188699a5.jpg'
img_path = '/media/whale/wsWin10/images/dog/dd92db98b99479db3619f62c724757a4.jpg' img = image.load_img(img_path, target_size=(224, 224)) plt.imshow(img)
plt.show( ) # ### 加载VGG16模型(包含全连接层) # In[3]: model = VGG16(include_top=True, weights='imagenet')
print(" type(model) = ", type(model)) # In[4]: x = image.img_to_array(img) x = np.expand_dims(x, axis=0) x = preprocess_input(x) print( "x.max() = ", x.max()) scores = model.predict(x) # In[10]: class_table = open('./data/synset_words', 'r')
lines = class_table.readlines()
print(" scores type: ", type(scores))
print(" scores shape: ", scores.shape)
print(" np.argmax(scores) = ", np.argmax(scores))
print('result is ', lines[np.argmax(scores)])
class_table.close() import sys
sys.exit()

。。。/wsWin10/wsPycharm/sklearnStu/Keras-Tutorials/08.vgg-16.py
Using TensorFlow backend.
2018-01-16 17:35:28.541700: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-01-16 17:35:28.627059: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-01-16 17:35:28.627317: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties:
name: GeForce GTX 850M major: 5 minor: 0 memoryClockRate(GHz): 0.9015
pciBusID: 0000:01:00.0
totalMemory: 3.95GiB freeMemory: 3.63GiB
2018-01-16 17:35:28.627334: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 850M, pci bus id: 0000:01:00.0, compute capability: 5.0)
(' type(model) = ', <class 'keras.engine.training.Model'>)
('x.max() = ', 151.061)
(' scores type: ', <type 'numpy.ndarray'>)
(' scores shape: ', (1, 1000))
(' np.argmax(scores) = ', 235)
('result is ', 'n02106662 German shepherd, German shepherd dog, German police dog, alsatian\n') Process finished with exit code 0

翻译下: 德国牧羊犬,德国牧羊犬,德国警犬,阿尔萨斯

caffe-ubuntu1604-gtx850m-i7-4710hq----VGG_ILSVRC_16_layers.caffemodel的更多相关文章

  1. 迁移学习︱艺术风格转化:Artistic style-transfer+ubuntu14.0+caffe(only CPU)

    说起来这门技术大多是秀的成分高于实际,但是呢,其也可以作为图像增强的工具,看到一些比赛拿他作训练集扩充,还是一个比较好的思路.如何在caffe上面实现简单的风格转化呢? 好像网上的博文都没有说清楚,而 ...

  2. caffe 利用VGG训练自己的数据

    写这个是因为有童鞋在跑VGG的时候遇到各种问题,供参考一下. 网络结构 以VGG16为例,自己跑的细胞数据 solver.prototxt: net: "/media/dl/source/E ...

  3. Windows caffe 跑mnist实例

       一. 装完caffe当然要来跑跑自带的demo,在examples文件夹下. 先来试试用于手写数字识别的mnist,在 examples/mnist/ 下有需要的代码文件,但是没有图像库. mn ...

  4. caffe训练模型中断的解决办法(利用solverstate)

    caffe训练过程中会生成.caffemodel和.solverstate文件,其中caffemodel为模型训练文件,可用于参数解析,solverstate为中间状态文件 当训练过程由于断电等因素中 ...

  5. 安装Caffe时出现的错误

    一.error MSB3073类错误 一般是由于CommonSettings.props配置出现错误. 第一处是你安装CUDA的版本号,第二次是你安装cudnn的路径. 也可参照http://blog ...

  6. TensorFlow模型转为caffe模型

    最近由于要将训练好的模型移植到硬件上,因此需要将TensorFlow转为caffe模型. caffe模型需要两个文件,一个是定义网络结构的prototxt,一个是存储了参数的caffemodel文件. ...

  7. finetune on caffe

    官方例程:http://caffe.berkeleyvision.org/gathered/examples/finetune_flickr_style.html 相应的中文说明:http://blo ...

  8. 使用Caffe完成图像目标检测 和 caffe 全卷积网络

    一.[用Python学习Caffe]2. 使用Caffe完成图像目标检测 标签: pythoncaffe深度学习目标检测ssd 2017-06-22 22:08 207人阅读 评论(0) 收藏 举报 ...

  9. Caffe源码-Net类(下)

    net.cpp部分源码 // 接着上一篇博客的介绍,此部分为Net类中前向反向计算函数,以及一些与HDF5文件或proto文件相互转换的函数. template <typename Dtype& ...

随机推荐

  1. ASP.NET三层架构的优点和缺点

    原文发布时间为:2009-10-24 -- 来源于本人的百度文章 [由搬家工具导入] 小项目,以后变动不大的不用三层架构。 ASP.NET三层结构说明 完善的三层结构的要求是:修改表现层而不用修改逻辑 ...

  2. Sql Server 2005 中的row_number() 分页技术

    原文发布时间为:2009-05-08 -- 来源于本人的百度文章 [由搬家工具导入] 在Sql Server 2005中,我们可以利用新增函数row_number()来更高效的实现分页存储   CRE ...

  3. 图表插件echars的使用案例

    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...

  4. Elasticsearch之pythonAPI简单使用

    elasticsearch自动补全建议功能 数据入库操作 ESmapping要求 PUT music { "mappings": { "_doc" : { &q ...

  5. Codeforces 766E Mahmoud and a xor trip(树形DP)

    题目链接 Mahmoud and a xor trip 树形DP.先考虑每个点到他本身的距离和,再算所有点两两距离和. 做的时候考虑二进制拆位即可. #include <bits/stdc++. ...

  6. linux文本处理常用命令

    linux文本处理常用命令   linux文本处理命令:grep.sed.printf.awk 1.grep grep的作用是按行查找字符,输出包含字符的行. #从文件查询 grep 'hello' ...

  7. 微信公众号开发C#系列-12、微信前端开发利器:WeUI

    1.前言 通过前面系列文章的学习与讲解,相信大家已经对微信的开发有了一个全新的认识.后端基本能够基于盛派的第三方sdk搞定大部分事宜,剩下的就是前端了.关于手机端的浏览器的兼容性问题相信一直是开发者们 ...

  8. Guru's Guide to SQL Server Architecture and Internals

    Guru's Guide to SQL Server Architecture and Internals

  9. 执行 innerHTML 里的 <script>

    原文:执行 innerHTML 里的 <script> 背景 有时候我们会有把一整段 HTML 动态塞进页面的需求,例如渲染了一个模板,从服务器端获取了一段广告代码等.一般情况下我们使用 ...

  10. 记录下我的阿里云centos服务器之路

    以下内容都已经过试验,边走边记,懒得排版 安装aphach yum install -y httpd systemctl start httpd netstat -tulp    安装桌面 尽量不用桌 ...