loadGraph(): ERRORNot found: Failed to load compute graph at
loadGraph(): ERRORNot found: Failed to load compute graph at
I am trying to run a c++ project using tesorflow ! But getting this error when loading the frozen_inference_graph.pb.
loadGraph(): ERRORNot found: Failed to load compute graph at '~/Desktop/Tensor/obdet/tensorflow-object-detection-cpp/demo/ssd_mobilenet_v1_egohands/frozen_inference_graph.pb'
How to solve it !
Source Code::
string ROOTDIR = "~/Desktop/Tensor/obdet/tensorflow-object-detection-cpp/";
string LABELS = "demo/ssd_mobilenet_v1_egohands/labels_map.pbtxt";
string GRAPH = "demo/ssd_mobilenet_v1_egohands/frozen_inference_graph.pb";
// Set input & output nodes names`
string inputLayer = "image_tensor:0";
vector<string> outputLayer = "detection_boxes:0", "detection_scores:0", "detection_classes:0", "num_detections:0";
// Load and initialize the model from .pb file
std::unique_ptr<tensorflow::Session> session;
string graphPath = tensorflow::io::JoinPath(ROOTDIR, GRAPH);
LOG(INFO) << "graphPath:" << graphPath;
Status loadGraphStatus = loadGraph(graphPath, &session);
//LOG(INFO) << "graphPath:" << graphPath;
if (!loadGraphStatus.ok())
LOG(ERROR) << "loadGraph(): ERROR" << loadGraphStatus;
//return -1;
else
LOG(INFO) << "loadGraph(): frozen graph loaded" << endl;
// Load labels map from .pbtxt file
std::map<int, std::string> labelsMap = std::map<int,std::string>();
Status readLabelsMapStatus = readLabelsMapFile(tensorflow::io::JoinPath(ROOTDIR, LABELS), labelsMap);
if (!readLabelsMapStatus.ok())
LOG(ERROR) << "readLabelsMapFile(): ERROR" << loadGraphStatus;
// return -1;
else
LOG(INFO) << "readLabelsMapFile(): labels map loaded with " << labelsMap.size() << " label(s)" << endl;
Load Function :
Status loadGraph(const string &graph_file_name,unique_ptr<tensorflow::Session> *session)
tensorflow::GraphDef graph_def;
Status load_graph_status =
ReadBinaryProto(tensorflow::Env::Default(), graph_file_name, &graph_def);
if (!load_graph_status.ok())
return tensorflow::errors::NotFound("Failed to load compute graph at '",
graph_file_name, "'");
session->reset(tensorflow::NewSession(tensorflow::SessionOptions()));
Status session_create_status = (*session)->Create(graph_def);
if (!session_create_status.ok())
return session_create_status;
return Status::OK();
graphPath
~
ROOTDIR
Yes ! graphpath was from! Thanks a lot :)
– mahbubcseju
Aug 31 at 10:51
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Most likely reason is that your
graphPath
is wrong. Assuming the file is where you say it is then I would try replacing the~
inROOTDIR
with an explicit path.– john
Aug 30 at 13:36