From d193554a5faf7a135861f9c46ce4e43d2a59cb1a Mon Sep 17 00:00:00 2001 From: Dmitry Kurtaev Date: Wed, 23 Oct 2024 09:29:05 +0300 Subject: [PATCH] OpenVINO friendly output names from non-compiled Model --- modules/dnn/src/ie_ngraph.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/dnn/src/ie_ngraph.cpp b/modules/dnn/src/ie_ngraph.cpp index 6e7b9f9be5..0897aaff1c 100644 --- a/modules/dnn/src/ie_ngraph.cpp +++ b/modules/dnn/src/ie_ngraph.cpp @@ -162,7 +162,9 @@ void InfEngineNgraphNet::createNet(Target targetId) { CV_LOG_DEBUG(NULL, "DNN/NGRAPH: Add 'Result' output: " << output_node_it->first); CV_Assert(output_node_it->second); auto out = std::make_shared(output_node_it->second->node); - out->set_friendly_name(output_node_it->first + (output_node_it->second->node.get_node()->get_output_size() == 1 ? "" : ".0")); + std::string name = output_node_it->first + (output_node_it->second->node.get_node()->get_output_size() == 1 ? "" : ".0") + CV_LOG_DEBUG(NULL, "DNN-IE: Change friendly name from " << out->get_friendly_name() << " to " << name); + out->set_friendly_name(name); outs.push_back(out); } CV_Assert_N(!inputs_vec.empty(), !outs.empty()); @@ -546,16 +548,22 @@ void InfEngineNgraphNet::forward(const std::vector >& outBlo { const std::string& name = it.get_node()->get_friendly_name(); auto blobIt = allBlobs.find(name); - CV_Assert(blobIt != allBlobs.end()); + if (blobIt == allBlobs.end()) + { + CV_Error(Error::StsAssert, format("Input blob with name %s not found", name.c_str())); + } reqWrapper->req.set_input_tensor(i++, isAsync ? copyBlob(blobIt->second) : blobIt->second); } i = 0; - for (const auto& it : netExec.outputs()) + for (const auto& it : cnn->outputs()) // Starts from OpenVINO 2024 CompiledModel changes output frindly names { const std::string& name = it.get_node()->get_friendly_name(); auto blobIt = allBlobs.find(name); - CV_Assert(blobIt != allBlobs.end()); + if (blobIt == allBlobs.end()) + { + CV_Error(Error::StsAssert, format("Output blob with name %s not found", name.c_str())); + } reqWrapper->req.set_output_tensor(i++, isAsync ? copyBlob(blobIt->second) : blobIt->second); }