1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #26208 from alexlyulkov:al/new-engine-caffe-parser

Modified Caffe parser to support the new dnn engine #26208

Now the Caffe parser supports both the old and the new engine. It can be selected using newEngine argument in PopulateNet.

All cpu Caffe tests work fine except:

- Test_Caffe_nets.Colorization
- Test_Caffe_layers.FasterRCNN_Proposal

Both these tests doesn't work because of the bug in the new net.forward function. The function takes the name of the desired target last layer, but uses this name as the name of the desired output tensor.
Also Colorization test contains a strange model with a Silence layer in the end, so it doesn't have outputs. The old parser just ignored it. I think, the proper solution is to run this model until the (number_of_layers - 2) layer using proper net.forward arguments in the test.

### 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 another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
alexlyulkov
2024-10-28 11:32:07 +03:00
committed by GitHub
parent 7b0a082dd4
commit a2fa1d49a4
12 changed files with 366 additions and 83 deletions
+6 -3
View File
@@ -112,7 +112,7 @@ class dnn_test(NewOpenCVTests):
def checkIETarget(self, backend, target):
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt')
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel')
net = cv.dnn.readNet(proto, model)
net = cv.dnn.readNet(proto, model, engine=cv.dnn.ENGINE_CLASSIC)
try:
net.setPreferableBackend(backend)
net.setPreferableTarget(target)
@@ -324,6 +324,9 @@ class dnn_test(NewOpenCVTests):
testScores, testBoxes, 0.5)
def test_async(self):
# bug: https://github.com/opencv/opencv/issues/26376
raise unittest.SkipTest("The new dnn engine does not support async inference")
timeout = 10*1000*10**6 # in nanoseconds (10 sec)
proto = self.find_dnn_file('dnn/layers/layer_convolution.prototxt')
model = self.find_dnn_file('dnn/layers/layer_convolution.caffemodel')
@@ -337,7 +340,7 @@ class dnn_test(NewOpenCVTests):
printParams(backend, target)
netSync = cv.dnn.readNet(proto, model)
netSync = cv.dnn.readNet(proto, model, engine=cv.dnn.ENGINE_CLASSIC)
netSync.setPreferableBackend(backend)
netSync.setPreferableTarget(target)
@@ -463,7 +466,7 @@ class dnn_test(NewOpenCVTests):
for backend, target in self.dnnBackendsAndTargets:
printParams(backend, target)
net = cv.dnn.readNet(model)
net = cv.dnn.readNet(model, engine=cv.dnn.ENGINE_CLASSIC)
net.setPreferableBackend(backend)
net.setPreferableTarget(target)