Skip to content

Instantly share code, notes, and snippets.

@haoxi911
Last active March 15, 2018 12:48
Show Gist options
  • Save haoxi911/1b43af29cd6b9ae07fabd3bafd39dd15 to your computer and use it in GitHub Desktop.
Save haoxi911/1b43af29cd6b9ae07fabd3bafd39dd15 to your computer and use it in GitHub Desktop.
Retrain Mobilenet_v1 with Oxford IIIT Pet dataset
# Train
cd ~/tensorflow/
source ./bin/activate
python tensorflow/tensorflow/examples/image_retraining/retrain.py \
--image_dir $(pwd)/datasets/oxford-iiit-pet/images/ \
--learning_rate=0.001 \
--testing_percentage=20 \
--validation_percentage=20 \
--train_batch_size=32 \
--validation_batch_size=-1 \
--flip_left_right True \
--random_scale=30 \
--random_brightness=30 \
--eval_step_interval=100 \
--how_many_training_steps=1000 \
--architecture mobilenet_1.0_224 \
--print_misclassified_test_images \
--output_graph=$(pwd)/datasets/oxford-iiit-pet/output_graph.pb \
--output_labels=$(pwd)/datasets/oxford-iiit-pet/output_labels.txt
# TF-Lite
cd ~/tensorflow/tensorflow/
bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=$(pwd)/../datasets/oxford-iiit-pet/output_graph.pb \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--output_file=$(pwd)/../datasets//oxford-iiit-pet/output_graph.tflite \
--inference_type=FLOAT \
--input_type=FLOAT \
--input_arrays=input \
--output_arrays=final_result \
--input_shapes=1,224,224,3
# Test
cd ~/tensorflow/tensorflow/
bazel-bin/tensorflow/examples/label_image/label_image \
--input_layer=input \
--output_layer=final_result \
--graph=$(pwd)/../datasets/oxford-iiit-pet/output_graph.pb \
--input_mean=128 \
--input_std=128 \
--image=$(pwd)/../datasets/oxford-iiit-pet/images/chihuahua/chihuahua_9.jpg \
--input_width=224 \
--input_height=224 \
--labels=$(pwd)/../datasets/oxford-iiit-pet/output_labels.txt
@haoxi911
Copy link
Author

2018-03-15 12:42:17.455515: I tensorflow/examples/label_image/main.cc:250] chihuahua (9): 0.985502
2018-03-15 12:42:17.455732: I tensorflow/examples/label_image/main.cc:250] sphynx (14): 0.0134067
2018-03-15 12:42:17.455790: I tensorflow/examples/label_image/main.cc:250] siamese (29): 0.000288703
2018-03-15 12:42:17.455934: I tensorflow/examples/label_image/main.cc:250] miniature pinscher (26): 0.000269378
2018-03-15 12:42:17.455998: I tensorflow/examples/label_image/main.cc:250] abyssinian (6): 7.23909e-05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment