TensorFlow(十四):谷歌图像识别网络inception-v3下载与查看结构
上代码:
import tensorflow as tf
import os
import tarfile
import requests #inception模型下载地址
inception_pretrain_model_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'
# inception_pretrain_model_url = 'http://download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz' #模型存放地址
inception_pretrain_model_dir = "inception_model"
if not os.path.exists(inception_pretrain_model_dir):
os.makedirs(inception_pretrain_model_dir) #获取文件名,以及文件路径
filename = inception_pretrain_model_url.split('/')[-1]
filepath = os.path.join(inception_pretrain_model_dir, filename) #下载模型
if not os.path.exists(filepath):
print("download: ", filename)
r = requests.get(inception_pretrain_model_url, stream=True)
with open(filepath, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
print("finish: ", filename)
#解压文件
tarfile.open(filepath, 'r:gz').extractall(inception_pretrain_model_dir) #模型结构存放文件
log_dir = 'inception_log'
if not os.path.exists(log_dir):
os.makedirs(log_dir) #classify_image_graph_def.pb为google训练好的模型
inception_graph_def_file = os.path.join(inception_pretrain_model_dir, 'classify_image_graph_def.pb')
# inception_graph_def_file = os.path.join(inception_pretrain_model_dir, 'inception_v4.ckpt')
with tf.Session() as sess:
#创建一个图来存放google训练好的模型
with tf.gfile.FastGFile(inception_graph_def_file, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='')
#保存图的结构
writer = tf.summary.FileWriter(log_dir, sess.graph)
writer.close()
结构:
打开cmd,进入inception_log目录:执行:tensorboard --logdir='C:\Users\FELIX\Desktop\tensor学习\inception_log'查看结构。
TensorFlow(十四):谷歌图像识别网络inception-v3下载与查看结构的更多相关文章
- TensorFlow:谷歌图像识别网络inception-v3下载与查看结构
学习博客: # https://www.cnblogs.com/felixwang2/p/9190731.html # https://www.cnblogs.com/felixwang2/p/919 ...
- linux基础-第十四单元 Linux网络原理及基础设置
第十四单元 Linux网络原理及基础设置 三种网卡模式图 使用ifconfig命令来维护网络 ifconfig命令的功能 ifconfig命令的用法举例 使用ifup和ifdown命令启动和停止网卡 ...
- Tensorflow学习(练习)—下载骨骼图像识别网络inception数据集
import tensorflow as tfimport osimport tarfileimport requests #inception模型下载地址inception_pretrain_mod ...
- 第十四单元 Linux网络原理及基础设置
·ifconfig命令来维护网络(详见linux系统管理P422) 1) 掌握ifconfig命令的功能:显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址.2) 灵活应用ifconfig命令 ...
- python简说(二十四)发送网络请求
一.get,post请求import requestsurl='http://127.0.0.1:8999/api/upload'# data = {'username':'testuser1','p ...
- Android问题集锦之三十四:android studio导入项目下载gradle-x.x.x-all.zip
每每打开github上的项目,都会先下载gradle.每一个项目都有自己的gradle构建程序,可是打开一个新项目就又一次下载gradle对于网络较差的情况真是苦不堪言.所以我们能够用已经下载好的放到 ...
- Spring Boot2(十四):单文件上传/下载,文件批量上传
文件上传和下载在项目中经常用到,这里主要学习SpringBoot完成单个文件上传/下载,批量文件上传的场景应用.结合mysql数据库.jpa数据层操作.thymeleaf页面模板. 一.准备 添加ma ...
- java web学习总结(二十四) -------------------Servlet文件上传和下载的实现
在Web应用系统开发中,文件上传和下载功能是非常常用的功能,今天来讲一下JavaWeb中的文件上传和下载功能的实现. 对于文件上传,浏览器在上传的过程中是将文件以流的形式提交到服务器端的,如果直接使用 ...
- 孤荷凌寒自学python第四十四天Python操作 数据库之准备工作
孤荷凌寒自学python第四十四天Python操作数据库之准备工作 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) 今天非常激动地开始接触Python的数据库操作的学习了,数据库是系统化设计 ...
随机推荐
- javascript进度条实现
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- MySQL性能测试调优
MySQL性能测试调优 操作系统 基本操作 查看磁盘分区mount选项 $ mount 永久修改分区mount选项(系统重启后生效) 修改文件 /etc/fstab 中对应分区的mount optio ...
- Qt定时器
PS: 本案例使用的是Qt 4.8.4版本,不同版本代码可能会有差异. 第一步: // 重写此虚函数(继承自QObject) virtual void timerEvent(QTimerEvent* ...
- bootstrap tab选项卡
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- ScrollView小记
常用代理方法: - (void)scrollViewDidScroll:(UIScrollView *)scrollView 只有 [self.scrolView setContentOffset: ...
- HTML5 使用localstorage 本地存储
HTML 本地存储介绍 最早的 Cookies 自然是大家都知道,问题主要就是太小,大概也就 4KB 的样子,而且 IE6 只支持每个域名20个cookies,太少了.优势就是大家都支持,而且支持得还 ...
- c# 定义和调用索引器
- 配置多网卡多IP的方式
[root@web01 conf.d]# cat ip.conf server { listen 10.0.0.7:80; server_name _; location ...
- find 查找文件的命令
find顾名思义就是查找,Linux下find命令提供相当多的查找条件,可以在众多文件或目录下查找你想要的任何文件或目录. 语法: find filename 我当前目录下有aaa.txt和bbb.t ...
- C#一些不太熟悉的类——扩展学习
Process.CloseMainWindow Method 通过向进程的主窗口发送关闭消息来关闭拥有用户界面的进程. 注解 进程执行时,其消息循环处于等待状态. 每次操作系统将 Windows 消息 ...