| 396 | } |
| 397 | |
| 398 | int main(int argc, char** argv) { |
| 399 | string graph = |
| 400 | "tensorflow/contrib/pi_examples/label_image/data/" |
| 401 | "tensorflow_inception_stripped.pb"; |
| 402 | string labels_file_name = |
| 403 | "tensorflow/contrib/pi_examples/label_image/data/" |
| 404 | "imagenet_comp_graph_label_strings.txt"; |
| 405 | int32 input_width = 299; |
| 406 | int32 input_height = 299; |
| 407 | int32 input_mean = 128; |
| 408 | int32 input_std = 128; |
| 409 | string input_layer = "Mul"; |
| 410 | string output_layer = "softmax"; |
| 411 | int32 video_width = 640; |
| 412 | int32 video_height = 480; |
| 413 | int print_threshold = 50; |
| 414 | string root_dir = ""; |
| 415 | std::vector<Flag> flag_list = { |
| 416 | Flag("graph", &graph, "graph file name"), |
| 417 | Flag("labels", &labels_file_name, "labels file name"), |
| 418 | Flag("input_width", &input_width, "image input width"), |
| 419 | Flag("input_height", &input_height, "image input height"), |
| 420 | Flag("input_mean", &input_mean, "transformed mean of input pixels"), |
| 421 | Flag("input_std", &input_std, "transformed std dev of input pixels"), |
| 422 | Flag("input_layer", &input_layer, "input layer name"), |
| 423 | Flag("output_layer", &output_layer, "output layer name"), |
| 424 | Flag("video_width", &video_width, "video width expected from device"), |
| 425 | Flag("video_height", &video_height, "video height expected from device"), |
| 426 | Flag("print_threshold", &print_threshold, |
| 427 | "print labels with scoe exceeding this"), |
| 428 | Flag("root_dir", &root_dir, |
| 429 | "interpret graph file name relative to this directory")}; |
| 430 | string usage = tensorflow::Flags::Usage(argv[0], flag_list); |
| 431 | const bool parse_result = tensorflow::Flags::Parse(&argc, argv, flag_list); |
| 432 | |
| 433 | if (!parse_result || argc != 1) { |
| 434 | LOG(ERROR) << "\n" << usage; |
| 435 | return -1; |
| 436 | } |
| 437 | |
| 438 | // First we load and initialize the model. |
| 439 | std::unique_ptr<tensorflow::Session> session; |
| 440 | string graph_path = tensorflow::io::JoinPath(root_dir, graph); |
| 441 | Status load_graph_status = LoadGraph(graph_path, &session); |
| 442 | if (!load_graph_status.ok()) { |
| 443 | LOG(ERROR) << load_graph_status; |
| 444 | return -1; |
| 445 | } |
| 446 | |
| 447 | std::vector<string> labels; |
| 448 | size_t label_count; |
| 449 | Status read_labels_status = |
| 450 | ReadLabelsFile(labels_file_name, &labels, &label_count); |
| 451 | if (!read_labels_status.ok()) { |
| 452 | LOG(ERROR) << read_labels_status; |
| 453 | return -1; |
| 454 | } |
| 455 |
nothing calls this directly
no test coverage detected