Training and Inference Demo Guide

If you would like the back story to this guide, navigate here and read my series on my first fight with training a machine learning model!

Let the demo guide begin…

This demo is targeted towards Google Cloud enthusiasts who want to show case machine learning in a disconnected environment, also involving “edge” devices with limited compute power to perform training and inference.

You have two options: you can use the flowers dataset as seen in this tutorial, or the OIRDS (overhead imagery) dataset. Please follow the same tutorial to attain the proper folder file structure to run the commands below.

**BEFORE GETTING ON STAGE**

  1. Install Tensorflow in your home directory
  2. Navigate to the directory that contains your sub-folders, including models, tf_files, etc…
  3. [Optional] Start Tensorboard:

tensorboard — logdir tf_files/training_summaries &

4. After launching tensorboard, open a new terminal tab, set the following variables:

IMAGE_SIZE=224
ARCHITECTURE=”mobilenet_0.50_${IMAGE_SIZE}”

**ON STAGE**

Launch training script in the same tab as above in the oirds_photos directory, or whatever you called your directory for this demo:

python -m scripts.retrain \
— bottleneck_dir=tf_files/bottlenecks \
— model_dir=tf_files/models/ \
— summaries_dir=tf_files/training_summaries/”${ARCHITECTURE}” \
— output_graph=tf_files/retrained_graph.pb \
— output_labels=tf_files/retrained_labels.txt \
— architecture=”${ARCHITECTURE}” \
— image_dir=tf_files/oirds_photos

  1. Training will take 4–5 minutes.
  2. Show Tensorboard training progress if desired (You can open TensorBoard in your browser)
  3. Open the photo file you are about to test (in this case it is : 46748000_1025_3841_1281_4097.jpeg)
  4. Run the script below to classify the image:

python -m scripts.label_image \
— graph=tf_files/retrained_graph.pb \
— image=tf_files/oirds_photos/pickup/46748000_1025_3841_1281_4097.jpeg

Note: If your command line/ terminal tab or window closes, make sure you re-set the IMAGE and ARCHITECTURE variables again.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store