Tensorflow学习(练习)—下载骨骼图像识别网络inception数据集

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_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‘)
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()

##################运行结果

download:  inception-2015-12-05.tgz
finish:  inception-2015-12-05.tgz

原文地址:https://www.cnblogs.com/herd/p/9481983.html

时间: 2024-08-30 13:36:35

Tensorflow学习(练习)—下载骨骼图像识别网络inception数据集的相关文章

tensorflow中导入下载到本地的mnist数据集

mnist数据集获取:可从Yann LeCun教授管网获取; tensorflow中可使用input_data.read_data_sets("/worker/mnistdata/", one_hot = True) 导入下载到本地的mnist数据集; "/worker/mnistdata/"为数据集存放的位置. import tensorflow as tf from tensorflow.examples.tutorials.mnist import input

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.te

8-3 下载Google图像识别网络inception-v3并查看结构

import tensorflow as tf import os import tarfile import requests # inception-v3 是googlenet的第三个版本 #inception模型下载地址 #inception_pretrain_model_url = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'#这里采用手动下载后直接放入下述模型存放地址中.

Tensorflow学习教程------利用卷积神经网络对mnist数据集进行分类_训练模型

原理就不多讲了,直接上代码,有详细注释. #coding:utf-8 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data',one_hot=True) #每个批次的大小 batch_size = 100 n_batch = mnist.train._num_examples // batch_

4_1网络学习第一天后感--网络数据下载

4_1网络学习第一天后感--网络数据下载 1.网络数据下载包括同步下载和异步下载,一般是使用异步下载,异步下载可以利用NSURLConnection这个类. 2.有关数据格式,有JSON格式(多数).XML格式.JSON格式如下: {} 代表字典,[] 代表数组 ,“” 代表字符串 , 100  代表NSNumber 3.分析网络接口 如:@"http://iappfree.candou.com:8080/free/applications/limited?currency=rmb&pa

TensorFlow学习路径【转】

作者:黄璞链接:https://www.zhihu.com/question/41667903/answer/109611087来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 前言:其实TensorFlow本身仅仅是一个分布式的高性能计算框架,想要用TF做深度学习,仅仅学习这个框架本身是没有太大意义的.因此应该将TF看作技术路线中的一个核心点,去掌握整个开发所需要的必要技术,知识.尤其是深度学习的基本原理,这对日后搭建模型,模型调参以至提出新的模型都是极其有用的.

【TensorFlow实战】TensorFlow实现经典卷积神经网络之Google Inception Net

Google Inception Net 0.前言 Google Inception Net首次出现在ILSVRC 2014比赛中,就以较大优势获得第一名.那届的Inception Net被称为Inception Net V1,它最大的特点就是控制了计算量和参数量的同时,获得了非常好的分类性能--top-5错误率6.67%,只有AlexNet的一半不到.Inception Net V1有22层深,比AlexNet的8层或者VGGNet的19层还要更深.但其计算量只有15亿次浮点运算,同时只有50

VC++/MFC(VC6)开发技术精品学习资料下载汇总

工欲善其事,必先利其器,VC开发MFC Windows程序,Visual C++或Visual Studio是必须的,恩,这里都给你总结好了,拿去吧:VC/MFC开发必备Visual C++.Visual Studio.MSDN等下载汇总,甭客气~  啊?还没有开始学C++?那你先学习C++语言基础吧,C/C++语言基础学习资料及视频教程请看这里. 史无前例的网络最全最强C/C++资料索引: C/C++编程语言学习资料尽收眼底 电子书+视频教程 VC++/MFC(VC6)开发技术精品学习资料下载

用tensorflow学习贝叶斯个性化排序(BPR)

在贝叶斯个性化排序(BPR)算法小结中,我们对贝叶斯个性化排序(Bayesian Personalized Ranking, 以下简称BPR)的原理做了讨论,本文我们将从实践的角度来使用BPR做一个简单的推荐.由于现有主流开源类库都没有BPR,同时它又比较简单,因此用tensorflow自己实现一个简单的BPR的算法,下面我们开始吧. 1. BPR算法回顾 BPR算法是基于矩阵分解的排序算法,它的算法训练集是一个个的三元组$<u,i,j>$,表示对用户u来说,商品i的优先级要高于商品j.训练成