mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 21:22:43 -06:00
dnn: accept 4-value pads in ONNX MaxUnpool and read them as [H, W]
This commit is contained in:
@@ -1382,9 +1382,11 @@ void ONNXImporter2::parseMaxUnpool(LayerParams& layerParams, const opencv_onnx::
|
||||
if (layerParams.has("pad"))
|
||||
{
|
||||
DictValue pads = layerParams.get("pad");
|
||||
CV_CheckEQ(pads.size(), 2, "");
|
||||
pool_pad_w = pads.get<int>(0);
|
||||
pool_pad_h = pads.get<int>(1);
|
||||
CV_CheckEQ(pads.size(), 4, "DNN/ONNX: MaxUnpool expects 4 pads values for 2D input");
|
||||
pool_pad_h = pads.get<int>(0);
|
||||
pool_pad_w = pads.get<int>(1);
|
||||
CV_CheckEQ(pads.get<int>(2), pool_pad_h, "DNN/ONNX: MaxUnpool supports only symmetric pads");
|
||||
CV_CheckEQ(pads.get<int>(3), pool_pad_w, "DNN/ONNX: MaxUnpool supports only symmetric pads");
|
||||
}
|
||||
layerParams.set("pool_pad_w", pool_pad_w);
|
||||
layerParams.set("pool_pad_h", pool_pad_h);
|
||||
|
||||
@@ -325,6 +325,12 @@ TEST_P(Test_ONNX_layers, MaxUnpool_non_square)
|
||||
testONNXModels("maxunpool_non_square", npy, 0, 0, false, false, 2);
|
||||
}
|
||||
|
||||
// pads are [top, left, bottom, right]; unequal H and W pads catch swapped axes.
|
||||
TEST_P(Test_ONNX_layers, MaxUnpool_pads)
|
||||
{
|
||||
testONNXModels("maxunpool_pads", npy, 0, 0, false, false, 2);
|
||||
}
|
||||
|
||||
// Opset 20 removed DFT's axis attribute; with no axis input, the axis defaults to -2.
|
||||
TEST_P(Test_ONNX_layers, DFT_opset20_default_axis)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user