Reads a model graph definition from disk, and creates a session object you can use to run it.
| 37 | // Reads a model graph definition from disk, and creates a session object you |
| 38 | // can use to run it. |
| 39 | Status LoadGraph(const string& graph_file_name, |
| 40 | std::unique_ptr<tensorflow::Session>* session) { |
| 41 | tensorflow::GraphDef graph_def; |
| 42 | Status load_graph_status = |
| 43 | ReadBinaryProto(tensorflow::Env::Default(), graph_file_name, &graph_def); |
| 44 | if (!load_graph_status.ok()) { |
| 45 | return tensorflow::errors::NotFound("Failed to load compute graph at '", |
| 46 | graph_file_name, "'"); |
| 47 | } |
| 48 | session->reset(tensorflow::NewSession(tensorflow::SessionOptions())); |
| 49 | Status session_create_status = (*session)->Create(graph_def); |
| 50 | if (!session_create_status.ok()) { |
| 51 | return session_create_status; |
| 52 | } |
| 53 | return Status::OK(); |
| 54 | } |
| 55 | |
| 56 | // Takes a file name, and loads a list of labels from it, one per line, and |
| 57 | // returns a vector of the strings. |
no test coverage detected