Hello guys!
I have a problem reading an onnx model I’ve converted from tensorflow.keras with tf2onnx.
It seems like the readNetFromONNX cannot interpret some of the gather nodes.
The exact command I used to convert the model from TF is:
python -m tf2onnx.convert --keras .\saved_model\ --output .\models\tf2onnx_keras.onnx --opset 14
Does anyone have an idea what could be wrong? Thanks in advance.
Here is a screenshot of the onnx model from netron.app
Code:
auto onnx_model = cv::dnn::readNetFromONNX("unet_all.onnx");
Error log:
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (429) cv::dnn::dnn4_v20210608::ONNXImporter::populateNet DNN/ONNX: loading ONNX v7 model produced by 'tf2onnx':1.10.0. Number of nodes = 212, inputs = 1, outputs = 1
OpenCV(4.5.3) Error: Assertion failed (indexMat.total() == 1) in cv::dnn::dnn4_v20210608::ONNXImporter::handleNode, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp, line 1842
[ERROR:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2127) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 1 outputs: [Gather]:(Shape__224:0)
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2131) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode Input[0] = 'Shape__820:0'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2131) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode Input[1] = 'Const__872'
[ INFO:0] global C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp (2135) cv::dnn::dnn4_v20210608::ONNXImporter::handleNode Output[0] = 'Shape__224:0'
OpenCV(4.5.3) Error: Unspecified error (> Node [Gather]:(Shape__224:0) parse error: OpenCV(4.5.3) C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1842: error: (-215:Assertion failed) indexMat.total() == 1 in function 'cv::dnn::dnn4_v20210608::ONNXImporter::handleNode'
> ) in cv::dnn::dnn4_v20210608::ONNXImporter::handleNode, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\onnx\onnx_importer.cpp, line 2146