diff options
author | Asim Shankar <ashankar@google.com> | 2017-03-15 12:24:05 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-03-15 13:47:51 -0700 |
commit | 5d39c44b88150f616d97117ece7c15a4a64a553c (patch) | |
tree | 6390d3c064b8ae7e4061eaff658fbd416d7405e0 /tensorflow/examples/label_image | |
parent | 7745c0ff41a8fa32c5edb5b6cd3fbb5577faca3b (diff) |
docs,label_image: Use a more recent inception v3 model.
The older model uses some deprecated ops. While that still works,
given that we have a new model, might as well use it.
Change: 150233334
Diffstat (limited to 'tensorflow/examples/label_image')
-rw-r--r-- | tensorflow/examples/label_image/README.md | 17 | ||||
-rw-r--r-- | tensorflow/examples/label_image/main.cc | 20 |
2 files changed, 17 insertions, 20 deletions
diff --git a/tensorflow/examples/label_image/README.md b/tensorflow/examples/label_image/README.md index 62385312b6..1103caf586 100644 --- a/tensorflow/examples/label_image/README.md +++ b/tensorflow/examples/label_image/README.md @@ -18,9 +18,8 @@ packaged in the repo because of its size. Instead, you must first download the file to the `data` directory in the source tree: ```bash -$ wget https://storage.googleapis.com/download.tensorflow.org/models/inception_dec_2015.zip -O tensorflow/examples/label_image/data/inception_dec_2015.zip - -$ unzip tensorflow/examples/label_image/data/inception_dec_2015.zip -d tensorflow/examples/label_image/data/ +$ curl -L "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz" | + tar -C tensorflow/examples/label_image/data -xz ``` Then, as long as you've managed to build the main TensorFlow framework, you @@ -46,16 +45,16 @@ This uses the default example image that ships with the framework, and should output something similar to this: ``` -I tensorflow/examples/label_image/main.cc:207] military uniform (866): 0.647299 -I tensorflow/examples/label_image/main.cc:207] suit (794): 0.0477195 -I tensorflow/examples/label_image/main.cc:207] academic gown (896): 0.0232407 -I tensorflow/examples/label_image/main.cc:207] bow tie (817): 0.0157355 -I tensorflow/examples/label_image/main.cc:207] bolo tie (940): 0.0145023 +I tensorflow/examples/label_image/main.cc:206] military uniform (653): 0.834306 +I tensorflow/examples/label_image/main.cc:206] mortarboard (668): 0.0218692 +I tensorflow/examples/label_image/main.cc:206] academic gown (401): 0.0103579 +I tensorflow/examples/label_image/main.cc:206] pickelhaube (716): 0.00800814 +I tensorflow/examples/label_image/main.cc:206] bulletproof vest (466): 0.00535088 ``` In this case, we're using the default image of Admiral Grace Hopper, and you can see the network correctly spots she's wearing a military uniform, with a high -score of 0.6. +score of 0.8. Next, try it out on your own images by supplying the --image= argument, e.g. diff --git a/tensorflow/examples/label_image/main.cc b/tensorflow/examples/label_image/main.cc index fa02401028..8e3f69a6d6 100644 --- a/tensorflow/examples/label_image/main.cc +++ b/tensorflow/examples/label_image/main.cc @@ -93,8 +93,8 @@ Status ReadTensorFromImageFile(string file_name, const int input_height, string input_name = "file_reader"; string output_name = "normalized"; - auto file_reader = tensorflow::ops::ReadFile(root.WithOpName(input_name), - file_name); + auto file_reader = + tensorflow::ops::ReadFile(root.WithOpName(input_name), file_name); // Now try to figure out what kind of file it is and decode it. const int wanted_channels = 3; tensorflow::Output image_reader; @@ -232,20 +232,18 @@ int main(int argc, char* argv[]) { // These are the command-line flags the program can understand. // They define where the graph and input data is located, and what kind of // input the model expects. If you train your own model, or use something - // other than GoogLeNet you'll need to update these. + // other than inception_v3, then you'll need to update these. string image = "tensorflow/examples/label_image/data/grace_hopper.jpg"; string graph = - "tensorflow/examples/label_image/data/" - "tensorflow_inception_graph.pb"; + "tensorflow/examples/label_image/data/inception_v3_2016_08_28_frozen.pb"; string labels = - "tensorflow/examples/label_image/data/" - "imagenet_comp_graph_label_strings.txt"; + "tensorflow/examples/label_image/data/imagenet_slim_labels.txt"; int32 input_width = 299; int32 input_height = 299; - int32 input_mean = 128; - int32 input_std = 128; - string input_layer = "Mul"; - string output_layer = "softmax"; + int32 input_mean = 0; + int32 input_std = 255; + string input_layer = "input"; + string output_layer = "InceptionV3/Predictions/Reshape_1"; bool self_test = false; string root_dir = ""; std::vector<Flag> flag_list = { |