There is INCEPTION-V3 model Python implementation on GitHub at:https://github.com/tensorflow/models/tree/master/inception
There is several shell scripts In/inception/inception/data folder. These scripts only can run on the 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 is used to store flowers data and flower train and validate data after processing. Almost environment variables is 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 the 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 would call another script build_image_data.py.
There is 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 would 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 was 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 theDATA_DIR.
Before training. We 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 does one step in addition before we start training. Cause these Python scripts is separated not in a Python package. We need to add a empty __init__.py file to inception folder. And make a replica of flowers_train.py on Parent-directory. Then execute the this script.
Make sure you have already installed TensorFlow on your windows. Notice, TensorFlow only supports Python 3.4+ on Windows, and there are both types TensorFlow, one is CPU only, another is T Ensorflow-gpu. If you have a GPU that has enough compute ability, you can choose the GPU version. Check installing guide to the TensorFlow website is helpful. Https://www.tensorflow.org/install/install_windows
We'll discuss some arguments in flower_train.py and after articles.
How to set the TensorFlow Inception-v3 model on Windows