I’ve trained yolov10 model and exported it in .onnx. Then I want to use it in my c++ code, but getting error during processing node with 2 inputs and 2 outputs.
Here is full output with this error:
[ERROR:0@0.126] global onnx_importer.cpp:1040 cv::dnn::dnn4_v20251223::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 2 outputs: [TopK]:(onnx_node!/model.23/TopK_1) from domain='ai.onnx'
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.13.0) Error: Unspecified error (> Node [TopK@ai.onnx]:(onnx_node!/model.23/TopK_1) parse error: OpenCV(4.13.0) C:\Users\pankovn\Downloads\opencv-4.13.0\modules\dnn\src\layers\topk_layer.cpp:102: error: (-2:Unspecified error) in function 'bool __cdecl cv::dnn::TopKLayerImpl::getMemoryShapes(const class std::vector<class std::vector<int,class std::allocator<int> >,class std::allocator<class std::vector<int,class std::allocator<int> > > > &,const int,class std::vector<class std::vector<int,class std::allocator<int> >,class std::allocator<class std::vector<int,class std::allocator<int> > > > &,class std::vector<class std::vector<int,class std::allocator<int> >,class std::allocator<class std::vector<int,class std::allocator<int> > > > &) const'
> > TopK: K is out of range (expected: 'K < input_shape[axis_normalized]'), where
> > 'K' is 300
> > must be less than
> > 'input_shape[axis_normalized]' is 300
> ) in cv::dnn::dnn4_v20251223::ONNXImporter::handleNode
OpenCV version: 4.13.0 Operating System / Platform: Windows 11