diff --git a/modules/dnn/src/onnx/onnx_importer.cpp b/modules/dnn/src/onnx/onnx_importer.cpp index 0e6d43284c..c0cefde16e 100644 --- a/modules/dnn/src/onnx/onnx_importer.cpp +++ b/modules/dnn/src/onnx/onnx_importer.cpp @@ -2605,7 +2605,8 @@ void ONNXImporter::parsePad(LayerParams& layerParams, const opencv_onnx::NodePro paddings = paddings.t(); layerParams.set("paddings", DictValue::arrayInt(paddings.ptr(), paddings.total())); - if (node_proto.input_size() == 3) + // check for non-null constant_value + if (node_proto.input_size() == 3 && !node_proto.input(2).empty()) { Mat value = getBlob(node_proto, 2); float padValue = (depth == CV_8S) ? (float)value.ptr()[0] : value.ptr()[0];