Reads a model graph definition from disk, and creates a session object you can use to run it.
| 237 | // Reads a model graph definition from disk, and creates a session object you |
| 238 | // can use to run it. |
| 239 | Status LoadGraph(string graph_file_name, |
| 240 | std::unique_ptr<tensorflow::Session>* session) { |
| 241 | tensorflow::GraphDef graph_def; |
| 242 | Status load_graph_status = |
| 243 | ReadBinaryProto(tensorflow::Env::Default(), graph_file_name, &graph_def); |
| 244 | if (!load_graph_status.ok()) { |
| 245 | return tensorflow::errors::NotFound("Failed to load compute graph at '", |
| 246 | graph_file_name, "'"); |
| 247 | } |
| 248 | session->reset(tensorflow::NewSession(tensorflow::SessionOptions())); |
| 249 | Status session_create_status = (*session)->Create(graph_def); |
| 250 | if (!session_create_status.ok()) { |
| 251 | return session_create_status; |
| 252 | } |
| 253 | return Status::OK(); |
| 254 | } |
| 255 | |
| 256 | // Analyzes the output of the Inception graph to retrieve the highest scores and |
| 257 | // their positions in the tensor, which correspond to categories. |
no test coverage detected