itsnine / yolov5-onnxruntime

YOLOv5 ONNX Runtime C++ inference code.
246 stars 58 forks source link

Invalid input name: �����U #22

Closed HXB-1997 closed 1 year ago

HXB-1997 commented 1 year ago

(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

HXB-1997 commented 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;

HH45137 commented 1 month 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;

可以用了,谢谢