How to set up Tensorflow inception-v3 model on Windows

來源:互聯網
上載者:User

標籤:histogram   guide   amp   ada   win   spec   download   tin   back   

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.

How to set up Tensorflow inception-v3 model on Windows

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.