mirror of
https://github.com/opencv/opencv.git
synced 2026-07-28 06:43:01 +04:00
Merge pull request #26394 from alexlyulkov:al/new-engine-tf-parser
Modified tensorflow parser for the new dnn engine #26394 ### 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 - [x] 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:
@@ -74,20 +74,15 @@ public class DnnTensorFlowTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testGetLayer() {
|
||||
List<String> layernames = net.getLayerNames();
|
||||
|
||||
assertFalse("Test net returned no layers!", layernames.isEmpty());
|
||||
|
||||
String testLayerName = layernames.get(0);
|
||||
|
||||
DictValue layerId = new DictValue(testLayerName);
|
||||
|
||||
assertEquals("DictValue did not return the string, which was used in constructor!", testLayerName, layerId.getStringValue());
|
||||
|
||||
Layer layer = net.getLayer(layerId);
|
||||
|
||||
assertEquals("Layer name does not match the expected value!", testLayerName, layer.get_name());
|
||||
List<String> layerNames = net.getLayerNames();
|
||||
assertFalse("Test net returned no layers!", layerNames.isEmpty());
|
||||
|
||||
int layerId = 0;
|
||||
for (String layerName: layerNames) {
|
||||
Layer layer = net.getLayer(layerId);
|
||||
assertEquals("Layer name does not match the expected value!", layerName, layer.get_name());
|
||||
layerId++;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkInceptionNet(Net net)
|
||||
@@ -98,12 +93,12 @@ public class DnnTensorFlowTest extends OpenCVTestCase {
|
||||
Mat inputBlob = Dnn.blobFromImage(image, 1.0, new Size(224, 224), new Scalar(0), true, true);
|
||||
assertNotNull("Converting image to blob failed!", inputBlob);
|
||||
|
||||
net.setInput(inputBlob, "input");
|
||||
net.setInput(inputBlob, "");
|
||||
|
||||
Mat result = new Mat();
|
||||
try {
|
||||
net.setPreferableBackend(Dnn.DNN_BACKEND_OPENCV);
|
||||
result = net.forward("softmax2");
|
||||
result = net.forward("");
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail("DNN forward failed: " + e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user