aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/pi_examples/label_image/label_image.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/pi_examples/label_image/label_image.cc')
-rw-r--r--tensorflow/contrib/pi_examples/label_image/label_image.cc41
1 files changed, 24 insertions, 17 deletions
diff --git a/tensorflow/contrib/pi_examples/label_image/label_image.cc b/tensorflow/contrib/pi_examples/label_image/label_image.cc
index 70f32f2199..ab19398ef2 100644
--- a/tensorflow/contrib/pi_examples/label_image/label_image.cc
+++ b/tensorflow/contrib/pi_examples/label_image/label_image.cc
@@ -23,9 +23,10 @@ limitations under the License.
//
// Full build instructions are at tensorflow/contrib/pi_examples/README.md.
-#include <fstream>
#include <jpeglib.h>
#include <setjmp.h>
+#include <fstream>
+#include <vector>
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/tensor.h"
@@ -297,7 +298,8 @@ int main(int argc, char* argv[]) {
// 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.
- string image = "tensorflow/contrib/pi_examples/label_image/data/"
+ string image =
+ "tensorflow/contrib/pi_examples/label_image/data/"
"grace_hopper.jpg";
string graph =
"tensorflow/contrib/pi_examples/label_image/data/"
@@ -313,27 +315,32 @@ int main(int argc, char* argv[]) {
string output_layer = "softmax";
bool self_test = false;
string root_dir = "";
- const bool parse_result = tensorflow::ParseFlags(
- &argc, argv, {Flag("image", &image), //
- Flag("graph", &graph), //
- Flag("labels", &labels), //
- Flag("input_width", &input_width), //
- Flag("input_height", &input_height), //
- Flag("input_mean", &input_mean), //
- Flag("input_std", &input_std), //
- Flag("input_layer", &input_layer), //
- Flag("output_layer", &output_layer), //
- Flag("self_test", &self_test), //
- Flag("root_dir", &root_dir)});
+ vector tensorflow::Flag > flag_list = {
+ Flag("image", &image, "image to be processed"),
+ Flag("graph", &graph, "graph to be executed"),
+ Flag("labels", &labels, "name of file containing labels"),
+ Flag("input_width", &input_width, "resize image to this width in pixels"),
+ Flag("input_height", &input_height,
+ "resize image to this height in pixels"),
+ Flag("input_mean", &input_mean, "scale pixel values to this mean"),
+ Flag("input_std", &input_std, "scale pixel values to this std deviation"),
+ Flag("input_layer", &input_layer, "name of input layer"),
+ Flag("output_layer", &output_layer, "name of output layer"),
+ Flag("self_test", &self_test, "run a self test"),
+ Flag("root_dir", &root_dir,
+ "interpret image and graph file names relative to this directory"),
+ };
+ string usage = tensorflow::Flags::Usage(argv[0], flag_list);
+ const bool parse_result = tensorflow::Flags::Parse(&argc, argv, flag_list);
if (!parse_result) {
- LOG(ERROR) << "Error parsing command-line flags.";
+ LOG(ERROR) << "\n" << usage;
return -1;
}
// We need to call this to set up global state for TensorFlow.
- tensorflow::port::InitMain(argv[0], &argc, &argv);
+ tensorflow::port::InitMain(usage, &argc, &argv);
if (argc > 1) {
- LOG(ERROR) << "Unknown argument " << argv[1];
+ LOG(ERROR) << "Unknown argument " << argv[1] << "\n" << usage;
return -1;
}