Keras之inception_v3使用
一、安装
必要:tensorflow,Keras
首次运行需要安装:
1)下载模型权重 inception_v3_weights_tf_dim_ordering_tf_kernels.h5
路径见前一篇
2)安装h5py
pip install h5py
3)安装PIL
遇到pip无法安装,以pillow替代,见Stack Overflow
二、参数说明
分类结果:
ImageNet的1000种object,对应模型分类结果的1000 classes:
text: imagenet 1000 class id to human readable labels
https://github.com/cjyanyi/keras_deep_learning_tutorial/blob/master/imagenet1000_clsid_to_human.txt
三、代码示例
import numpy as np
from keras.preprocessing import image
from keras.applications import inception_v3 img = image.load_img("xxx.jpg", target_size=(299, 299))
input_image = image.img_to_array(img)
input_image /= 255.
input_image -= 0.5
input_image *= 2.
# Add a 4th dimension for batch size (Keras)
input_image = np.expand_dims(input_image, axis=0) # Run the image through the NN
predictions = model.predict(input_image) # Convert the predictions into text
predicted_classes = inception_v3.decode_predictions(predictions, top=1)
imagenet_id, name, confidence = predicted_classes[0][0]
print("This is a {} with {:-4}% confidence!".format(name, confidence * 100))
input_image 是一个默认大小:1*299*299*3 的4维向量(列表)
Keras之inception_v3使用的更多相关文章
- Keras官方中文文档:常见问题与解答
所属分类:Keras Keras FAQ:常见问题 如何引用Keras? 如何使Keras调用GPU? 如何在多张GPU卡上使用Keras "batch", "epoch ...
- [Deep-Learning-with-Python] Keras高级概念
Keras API 目前为止,介绍的神经网络模型都是通过Sequential模型来实现的.Sequential模型假设神经网络模型只有一个输入一个输出,而且模型的网络层是线性堆叠在一起的. 这是一个经 ...
- keras系列︱迁移学习:利用InceptionV3进行fine-tuning及预测、完美案例(五)
引自:http://blog.csdn.net/sinat_26917383/article/details/72982230 之前在博客<keras系列︱图像多分类训练与利用bottlenec ...
- keras系列︱Application中五款已训练模型、VGG16框架(Sequential式、Model式)解读(二)
引自:http://blog.csdn.net/sinat_26917383/article/details/72859145 中文文档:http://keras-cn.readthedocs.io/ ...
- 【Keras学习】常见问题与解答
Keras FAQ:常见问题 如何引用Keras? 如果Keras对你的研究有帮助的话,请在你的文章中引用Keras.这里是一个使用BibTex的例子 @misc{chollet2015keras, ...
- keras调用预训练模型分类
在网上看到一篇博客,地址https://www.pyimagesearch.com/2017/03/20/imagenet-vggnet-resnet-inception-xception-keras ...
- Keras(二)Application中五款已训练模型、VGG16框架解读
Application的五款已训练模型 + H5py简述 Keras的应用模块Application提供了带有预训练权重的Keras模型,这些模型可以用来进行预测.特征提取和finetune. 后续还 ...
- Keras 训练 inceptionV3 并移植到OpenCV4.0 in C++
1. 训练 # --coding:utf--- import os import sys import glob import argparse import matplotlib.pyplot as ...
- 我的Keras使用总结(4)——Application中五款预训练模型学习及其应用
本节主要学习Keras的应用模块 Application提供的带有预训练权重的模型,这些模型可以用来进行预测,特征提取和 finetune,上一篇文章我们使用了VGG16进行特征提取和微调,下面尝试一 ...
随机推荐
- deno学习三 官方提供的方便deno 安装方式
早起deno 使用了golang 开发,同时需要protobuf 进行数据的序列化以及反序列化处理 当前的deno 已经使用rust 进行了开发,同时官方提供的安装方式也很方便了,不需要 那么复杂的编 ...
- RESTful Web API 理解
REST 是一种应用架构风格,不是一种标准,是面向资源架构(ROA)风格,与具体技术平台无关,REST架构的应用未必建立在Web之上,与之对应的是传统的Web Service 采用的面向操作的RPC架 ...
- TypeScript 之 声明文件的发布
https://www.tslang.cn/docs/handbook/declaration-files/publishing.html 发布声明文件到npm,有两种方式: 与你的npm包捆绑在一起 ...
- ipset可使iptables一次性封多个ip
ipset是什么? ipset是iptables的扩展,它允许你创建 匹配整个地址集合的规则.而不像普通的iptables链只能单IP匹配, ip集合存储在带索引的数据结构中,这种结构即时集合比较大也 ...
- linux centos 安装php的memcache扩展
一.centos6.5 yum安装php的memcache扩展 搜索memcache yum search memcache 有了,现在可以安装了 yum -y install memcached m ...
- python selenium-webdriver 生成测试报告 (十四)
测试最后的一个重要的过程就是生成一份完整的测试报告,生成测试报告的主要是通过python的一个第三方模块HTMLTestRunner.py生成,但是生成的测试报告不是特别的美观,而且没有办法统计测试结 ...
- Oracle 增加、修改、删除字段
分别对T_USER表 进行增加name字段, 修改name字段,删除name字段 /*增加列表*/ ALTER TABLE T_USERS ADD name varchar2(512) ; /*删除列 ...
- MySQL的吞吐量
MySQL 的QPS吞吐量或者说TPS与很多因素有关,例如CPU.内存以及硬盘等. <高性能MySQL>第三版 1.5小节对各个版本的MySQL进行了测试,其结果如下. 测试机器 测试机器 ...
- grep 正则问题 this version of PCRE is compiled without UTF support
问题 在使用grep -P,出现如下报错: grep: this version of PCRE is compiled without UTF support 原因 有些系统支持的正则规范不同. 解 ...
- Qt 中的事件处理(二)
1. 回顾事件传递的过程 ①源头:操作系统 操作系统检测到用户的动作时,就会产生一个系统消息,系统消息就会被发送到正在运行的Qt应用程序中, ②应用程序收到系统消息后, 他会将系统消息翻译成对应的 ...