main.cc
// Analyzes the output of the Inception graph to retrieve the highest scores and
// their positions in the tensor, which correspond to categories.
Analyzes the output of the Inception graph to retrieve the highest scores and
their positions in the tensor, which correspond to categories.
Analyzes the output of the Inception graph to retrieve the highest scores and their positions in the tensor which correspond to categories .
Status GetTopLabels(const std::vector<Tensor> &outputs, int how_many_labels,
                    Tensor *indices, Tensor *scores) {
  auto root = tensorflow::Scope::NewRootScope();
  using namespace ::tensorflow::ops; 
  string output_name = "top_k";
  TopK(root.WithOpName(output_name), outputs[0], how_many_labels);
  tensorflow::GraphDef graph;
  TF_RETURN_IF_ERROR(root.ToGraphDef(&graph));
  std::unique_ptr<tensorflow::Session> session(
      tensorflow::NewSession(tensorflow::SessionOptions()));
  TF_RETURN_IF_ERROR(session->Create(graph));
  std::vector<Tensor> out_tensors;
  TF_RETURN_IF_ERROR(session->Run({}, {output_name + ":0", output_name + ":1"},
                                  {}, &out_tensors));
  *scores = out_tensors[0];
  *indices = out_tensors[1];
  return Status::OK();
}
Status GetTopLabels ( const std :: vector < Tensor > & outputs , int how_many_labels , Tensor * indices , Tensor * scores ) { auto root = tensorflow :: Scope :: NewRootScope ( ) ; using namespace :: tensorflow :: ops ; string output_name = " " ; TopK ( root . WithOpName ( output_name ) , outputs [ 0 ] , how_many_labels ) ; tensorflow :: GraphDef graph ; TF_RETURN_IF_ERROR ( root . ToGraphDef ( & graph ) ) ; std :: unique_ptr < tensorflow :: Session > session ( tensorflow :: NewSession ( tensorflow :: SessionOptions ( ) ) ) ; TF_RETURN_IF_ERROR ( session -> Create ( graph ) ) ; std :: vector < Tensor > out_tensors ; TF_RETURN_IF_ERROR ( session -> Run ( { } , { output_name + " " , output_name + " " } , { } , & out_tensors ) ) ; * scores = out_tensors [ 0 ] ; * indices = out_tensors [ 1 ] ; return Status :: OK ( ) ; }
Analyzes the output of the Inception graph to retrieve the highest scores and
their positions in the tensor, which correspond to categories.
Analyzes the output of the Inception graph to retrieve the highest scores and their positions in the tensor which correspond to categories .
// NOLINT(build/namespaces) // This runs the GraphDef network definition that we've just constructed, and // returns the results in the output tensors. // The TopK node returns two outputs, the scores and their original indices, // so we have to append :0 and :1 to specify them both.