Closed HXB-1997 closed 1 year ago
解决方案:detector.cpp将
// inputNames.push_back(session.GetInputName(0, allocator)); // outputNames.push_back(session.GetOutputName(0, allocator));
替换为
` auto input_name = session.GetInputNameAllocated(0, allocator);
inputNodeNameAllocatedStrings.push_back(std::move(input_name));
inputNames.push_back(inputNodeNameAllocatedStrings.back().get());
auto output_name = session.GetOutputNameAllocated(0, allocator);
outputNodeNameAllocatedStrings.push_back(std::move(output_name));
outputNames.push_back(outputNodeNameAllocatedStrings.back().get());`
并且头文件增加:
// Inputs std::vector<Ort::AllocatedStringPtr> inputNodeNameAllocatedStrings; std::vector<const char*> inputNames; // Outputs std::vector<Ort::AllocatedStringPtr> outputNodeNameAllocatedStrings; std::vector<const char*> outputNames;
解决方案:detector.cpp将
// inputNames.push_back(session.GetInputName(0, allocator)); // outputNames.push_back(session.GetOutputName(0, allocator));
替换为 ` auto input_name = session.GetInputNameAllocated(0, allocator); inputNodeNameAllocatedStrings.push_back(std::move(input_name)); inputNames.push_back(inputNodeNameAllocatedStrings.back().get());auto output_name = session.GetOutputNameAllocated(0, allocator); outputNodeNameAllocatedStrings.push_back(std::move(output_name)); outputNames.push_back(outputNodeNameAllocatedStrings.back().get());`
并且头文件增加:
// Inputs std::vector<Ort::AllocatedStringPtr> inputNodeNameAllocatedStrings; std::vector<const char*> inputNames; // Outputs std::vector<Ort::AllocatedStringPtr> outputNodeNameAllocatedStrings; std::vector<const char*> outputNames;
可以用了,谢谢
(CUDA113+CUDNN82) han@han:~/Desktop/hxb_projects/CPP_Instance/10-30/git_3/yolov5-onnxruntime/build$ ./yolo_ort --model_path /home/han/Desktop/hxb_projects/CPP_Instance/10-30/git_3/yolov5-onnxruntime/models/yolov5s.onnx --image /home/han/Desktop/hxb_projects/CPP_Instance/10-30/git_3/yolov5-onnxruntime/images/bus.jpg --class_names /home/han/Desktop/hxb_projects/CPP_Instance/10-30/git_3/yolov5-onnxruntime/coco.names Inference device: CPU Input shape: 1 Input shape: 3 Input shape: 640 Input shape: 640 Input name: images Output name: images Model was initialized. Invalid input name: �����U