dnn: improve logging, catch import errors#21322
Conversation
| static const DispatchMap buildDispatchMap(); | ||
|
|
||
| int onnx_opset; // OperatorSetIdProto for 'onnx' domain | ||
| void parseOperatorSet(); |
| else | ||
| { | ||
| // OpenCV don't know other opsets | ||
| CV_LOG_WARNING(NULL, "DNN/ONNX: unsupported opset[" << i << "]: name='" << domain << "' version=" << version); |
There was a problem hiding this comment.
should we emit error here?
There was a problem hiding this comment.
I think we should change the condition to domain.empty() || domain == "ai.onnx" and emit the error if running normally, otherwise we should keep going(if DNN_DIAGNOSTICS_RUN is true).
There was a problem hiding this comment.
It is 3.4 branch, there is no DNN_DIAGNOSTICS_RUN
| CV_LOG_WARNING(NULL, "DNN/ONNX: can't handle node with " << node_proto.input_size() << " inputs and " << node_proto.output_size() << " outputs: " | ||
| << cv::format("[%s@%s]:(%s)", layer_type.c_str(), layer_type_domain.c_str(), name.c_str()) | ||
| ); | ||
| CV_Error(Error::StsNotImplemented, cv::format("ONNX: unsupported domain: %s", layer_type_domain.c_str())); |
There was a problem hiding this comment.
Added error for non-ONNX domain.
There was a problem hiding this comment.
We might want to skip CV_Error if DNN_DIAGNOSTICS_RUN is true.
| layerParams.set("mode", "opencv_linear"); | ||
|
|
||
| // input = [X, scales], [X, roi, scales] or [x, roi, scales, sizes] | ||
| int foundScaleId = hasDynamicShapes ? node_proto.input_size() - 1 |
There was a problem hiding this comment.
avoid using of hasDynamicShapes checks.
Such checks should be eliminated.
|
|
||
| void ONNXImporter::parseOperatorSet() | ||
| { | ||
| int ir_version = model_proto.has_ir_version() ? (int)model_proto.ir_version() : -1; |
| else | ||
| { | ||
| // OpenCV don't know other opsets | ||
| CV_LOG_WARNING(NULL, "DNN/ONNX: unsupported opset[" << i << "]: name='" << domain << "' version=" << version); |
There was a problem hiding this comment.
I think we should change the condition to domain.empty() || domain == "ai.onnx" and emit the error if running normally, otherwise we should keep going(if DNN_DIAGNOSTICS_RUN is true).
| CV_LOG_WARNING(NULL, "DNN/ONNX: can't handle node with " << node_proto.input_size() << " inputs and " << node_proto.output_size() << " outputs: " | ||
| << cv::format("[%s@%s]:(%s)", layer_type.c_str(), layer_type_domain.c_str(), name.c_str()) | ||
| ); | ||
| CV_Error(Error::StsNotImplemented, cv::format("ONNX: unsupported domain: %s", layer_type_domain.c_str())); |
There was a problem hiding this comment.
We might want to skip CV_Error if DNN_DIAGNOSTICS_RUN is true.
| for (int j = 0; j < inpShape.size(); ++j) | ||
| shapeMat.at<int>(j) = inpShape[j]; | ||
| bool isDynamicShape = false; | ||
| for (int j = 0; j < (int)inpShape.size(); ++j) |
| // opset-11: input = [X, roi, scales] or [x, roi, scales, sizes] | ||
| int foundScaleId = node_proto.input_size() == 2 ? 1 : 2; | ||
|
|
||
| Mat scales = getBlob(node_proto, foundScaleId); |
There was a problem hiding this comment.
Won't getBlob fail, if it doesn't find scales blob?
The condition below seems fragile.
There was a problem hiding this comment.
scales can be empty. getBlob() doesn't fail in that case.
https://github.com/onnx/onnx/blob/master/docs/Operators.md#Resize
The number of elements of 'scales' should be the same as the rank of input 'X'. One of 'scales' and 'sizes' MUST be specified and it is an error if both are specified. If 'sizes' is needed, the user can use an empty string as the name of 'scales' in this operator's input list.
" == 4" condition looks wrong. Reworked for better error messages.
|
👍 |
relates #19347 (debug helper for the issue)
relates #18145 (incomplete dynamic shapes support)