loadGraph():找不到错误:无法在处加载计算图 我试图使用TESORFROW运行C++项目!但在加载冻结的\u推断\u graph.pb时出现此错误。

loadGraph():找不到错误:无法在处加载计算图 我试图使用TESORFROW运行C++项目!但在加载冻结的\u推断\u graph.pb时出现此错误。,c++,tensorflow,C++,Tensorflow,loadGraph():找不到错误:未能在“~/Desktop/Tensor/obdet/tensorflow对象检测cpp/demo/ssd\u mobilenet\u v1\u egohands/Friented\u推断\u graph.pb”加载计算图。 如何解决它 源代码:: string ROOTDIR = "~/Desktop/Tensor/obdet/tensorflow-object-detection-cpp/"; string LABELS = "demo/ssd_mobil

loadGraph():找不到错误:未能在“~/Desktop/Tensor/obdet/tensorflow对象检测cpp/demo/ssd\u mobilenet\u v1\u egohands/Friented\u推断\u graph.pb”加载计算图。

如何解决它

源代码::

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;
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();
}
string ROOTDIR=“~/Desktop/Tensor/obdet/tensorflow对象检测cpp/”;
string LABELS=“demo/ssd\u mobilenet\u v1\u egohands/LABELS\u map.pbtxt”;
string GRAPH=“demo/ssd\u mobilenet\u v1\u egohands/freezed\u interference\u GRAPH.pb”;
//设置输入和输出节点名称`
字符串inputLayer=“image\u tensor:0”;
向量输出层={“检测框:0”,“检测分数:0”,“检测类:0”,“数量检测:0”};
//从.pb文件加载并初始化模型
std::唯一的ptr会话;
字符串graphPath=tensorflow::io::JoinPath(ROOTDIR,GRAPH);

日志(信息)最可能的原因是您的
graphPath
错误。假设文件位于您所说的位置,那么我将尝试用显式路径替换
ROOTDIR
中的
~
。是的!graphpath是从哪里来的!非常感谢:)