How to set up Tensorflow inception-v3 model on Windows

There is Inception-v3 model python implementation on GitHub at: https://github.com/tensorflow/models/tree/master/inception

There are several shell scripts in /inception/inception/data folder. these scripts only can run on Linux OS, especially on Ubuntu. So. how can we set up the Inception-v3 model on Windows. let‘s dive into these scripts code.

In download_and_preprocess_flowers.sh. first, the script download flower_photo.tgz file from the web. second, make some directories and set some environment. these folders are used to store flowers data and flower train and validate data after processing. almost environment variables are used as the argument in last scripts call.

  • DATA_DIR : root directory after unpacking flower_photo.tgz file.
  • TRAIN_DIRECTORY : the sub-directory of flower data. always be "flowers-data/raw-data/train".
  • VALIDATION_DIRECTORY: the sub-directory of flower data that store pictures for validating. always be "flowers-data/raw-data/validation".
  • LABELS_FILE: the file path of lable.txt, always be "flowers-data/raw-data/labels.txt".
  • OUTPUT_DIRECTORY : somewhere to store processed data.

Then, the script will call another script build_image_data.py.

There are some arguments in this script. we can use environment variables we just set before or set the specific path to these arguments. notice, we just call the build_image_data.py script directly with a command: python build_image_data.py --train_directory="${TRAIN_DIRECTORY}" --validation_directory="${VALIDATION_DIRECTORY}" --output_directory="${OUTPUT_DIRECTORY}" --labels_file="${LABELS_FILE}

this script will convert separated pictures to a union file batch with TFRecords format with Examples protos.

The Example proto:
contains the following fields:

image/encoded: string containing JPEG encoded image in RGB colorspace
image/height: integer, image height in pixels
image/width: integer, image width in pixels
image/colorspace: string, specifying the colorspace, always ‘RGB‘
image/channels: integer, specifying the number of channels, always 3
image/format: string, specifying the format, always‘JPEG‘

image/filename: string containing the basename of the image file
e.g. ‘n01440764_10026.JPEG‘ or ‘ILSVRC2012_val_00000293.JPEG‘
image/class/label: integer specifying the index in a classification layer.
The label ranges from [0, num_labels] where 0 is unused and left as
the background class.
image/class/text: string specifying the human-readable version of the label
e.g. ‘dog‘

After processing, we can find some training and validation files in the DATA_DIR. 

Before training. we have to do some adjustment to the source code. because Inception-v3 is written with an older version of tensorflow. some API has already discarded.

  • tf.scalar_summary    ->  tf.summary.scalar
  • tf.histogram_summary -> tf.summary.histogram
  • tf.merge_summary  -> tf.summary.merge
  • tf.train.SummaryWriter -> tf.summary.FileWriter
  • tf.concat(0,[ymin, xmin, ymax, xmax]) -> tf.concat([ymin, xmin, ymax, xmax],0)  switch argument.

      Maybe, there also has some error. just look up tensorflow documentation and change it.

We also need to do one step in addition before we start training. cause these python scripts are separated not in a python package. we need to add an empty __init__.py file to inception folder. and make a replica of flowers_train.py on parent-directory. then execute this script.

Make sure you have already installed tensorflow on your windows. notice, tensorflow only supports python 3.4+ on Windows, and there are two types tensorflow, one is CPU only, another is tensorflow-GPU. if you have a GPU have enough compute ability, you can choose the GPU version.  check Installing guide on the tensorflow website is helpful. https://www.tensorflow.org/install/install_windows

We will discuss some arguments in flower_train.py in after articles.

时间: 2024-10-05 04:49:09

How to set up Tensorflow inception-v3 model on Windows的相关文章

脸型分类-Face shape classification using Inception v3

本文链接:https://blog.csdn.net/u011961856/article/details/77984667函数解析github 代码:https://github.com/adonistio/inception-face-shape-classifier CLASSIFY_FACE.py1用于运行训练好的Inception model,对输入图像进行分类. CLASSIFY_FACE_CONFUSION.py1与CLASSIFY_FACE.PY类似,但是讲述如结果和一个困惑度矩

1、VGG16 2、VGG19 3、ResNet50 4、Inception V3 5、Xception介绍——迁移学习

ResNet, AlexNet, VGG, Inception: 理解各种各样的CNN架构 本文翻译自ResNet, AlexNet, VGG, Inception: Understanding various architectures of Convolutional Networks,原作者保留版权 卷积神经网络在视觉识别任务上的表现令人称奇.好的CNN网络是带有上百万参数和许多隐含层的"庞然怪物".事实上,一个不好的经验规则是:网络越深,效果越好.AlexNet,VGG,Inc

深度学习面试题29:GoogLeNet(Inception V3)

目录 使用非对称卷积分解大filters 重新设计pooling层 辅助构造器 使用标签平滑 参考资料 在<深度学习面试题20:GoogLeNet(Inception V1)>和<深度学习面试题26:GoogLeNet(Inception V2)>中对前两个Inception版本做了介绍,下面主要阐述V3版本的创新点 使用非对称卷积分解大filters InceptionV3中在网络较深的位置使用了非对称卷积,他的好处是在不降低模型效果的前提下,缩减模型的参数规模,在<深度学

下载inception v3 google训练好的模型并解压08-3

import tensorflow as tf import os import tarfile import requests #模型下载地址 inception_pretrain_model_url='http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz' #模型存放地址 inception_pretrain_model_dir="inception_model" if not o

TensorFlow 系列一(在Windows下的安装)

(整体流程参照 https://blog.csdn.net/u011473714/article/details/80746362,感谢博主的分析) 首先需要下载Anaconda,其次安装TensorFlow,在启动应用时的一些注意事项. 一.下载Anaconda tensorflow是基于python脚本语言的,是一种高级应用,它必须依赖于底层的应用发挥作用.因此需要安装python,当然还需要安装numpy.scipy.six.matplotlib等几十个扩展包.如果一个个安装,十分耗费时间

Tensorflow和pytorch安装(windows安装)

一. Tensorflow安装 1. Tensorflow介绍 Tensorflow是广泛使用的实现机器学习以及其它涉及大量数学运算的算法库之一.Tensorflow由Google开发,是GitHub上最受欢迎的机器学习库之一.Google几乎在所有应用程序中都使用Tensorflow来实现机器学习. 例如,如果您使用到了Google照片或Google语音搜索,那么您就间接使用了Tensorflow模型.它们在大型Google硬件集群上工作,在感知任务方面功能强大. 2.Tensorflow安装

tensorflow gpu安装配置(windows,linux)

流程: 1.先安装显卡驱动 禁用 X 服务(关闭图形界面,最好备用一台电脑) --不能通过远程控制实现后面的操作.所以这个部分还需要在本地上操作.备用一台电脑的原因是可以在另外一台电脑上看接下来的步骤该如何操作. 出现黑屏,解决方法: 2.安装CUDA 3.CUDNN 1. ubuntu16.04系统run方式安装nvidia显卡驱动 来自 <https://blog.csdn.net/xunan003/article/details/81665835> 2. ubuntu16.04安装ten

使用tensorflow的retrain.py训练图片分类器

参考 https://hackernoon.com/creating-insanely-fast-image-classifiers-with-mobilenet-in-tensorflow-f030ce0a2991 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py https://codelabs.developers.google.com/c

TensorFlow(十七):训练自己的图片分类模型

(一)下载inception-v3--见TensorFlow(十四) (二)准备训练用的图片集,因为我没有图片集,所以写了个自动抓取百度图片的脚本-见抓取百度图片 (三)创建retrain.py文件,进行重训练.(因为之前遇到不同版本上的不同,遇到过坑,上源码) # -*- coding: utf-8 -*- # @Author : Felix Wang # @time : 2018/6/27 11:46 # Copyright 2015 The TensorFlow Authors. All