1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #21066 from andrewerf:21052-openvino-native-onnx

Native ONNX to Inference Engine backend #21066

Resolves #21052

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
- [x] The PR is proposed to proper branch
- [x] There is reference to original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
andrewerf
2023-10-20 11:49:27 +03:00
committed by GitHub
parent 1aa4621777
commit b44cb33d2f
3 changed files with 38 additions and 6 deletions
+30
View File
@@ -6,6 +6,7 @@
// Third party copyrights are property of their respective owners.
#include "test_precomp.hpp"
#include "npy_blob.hpp"
#include <opencv2/core/ocl.hpp>
#include <opencv2/core/opencl/ocl_defs.hpp>
#include <opencv2/dnn/layer.details.hpp> // CV_DNN_REGISTER_LAYER_CLASS
@@ -871,6 +872,35 @@ TEST_P(Test_Model_Optimizer, flexible_inputs)
normAssert(ref, out, 0, 0);
}
TEST_P(Test_Model_Optimizer, readONNX)
{
const Backend backendId = get<0>(GetParam());
const Target targetId = get<1>(GetParam());
ASSERT_EQ(DNN_BACKEND_INFERENCE_ENGINE_NGRAPH, backendId);
const std::string& model = findDataFile("dnn/onnx/models/convolution.onnx");
std::vector<Net> nets = {
// Old API
readNetFromModelOptimizer(model, ""),
readNet("", model, "dldt"),
// New API
readNetFromModelOptimizer(model),
readNet(model, "", "openvino")
};
Mat inp = blobFromNPY(findDataFile("dnn/onnx/data/input_convolution.npy"));
Mat ref = blobFromNPY(findDataFile("dnn/onnx/data/output_convolution.npy"));
for (int i = 0; i < nets.size(); ++i) {
nets[i].setPreferableTarget(targetId);
nets[i].setInput(inp);
Mat out = nets[i].forward();
normAssert(out, ref, format("Index: %d", i).c_str());
}
}
INSTANTIATE_TEST_CASE_P(/**/, Test_Model_Optimizer,
dnnBackendsAndTargetsIE()
);