From ae46bcd93e5d7b377bfeb697131da0a80dc1e1de Mon Sep 17 00:00:00 2001 From: bharath <33729709+bharath5673@users.noreply.github.com> Date: Fri, 10 Jun 2022 09:07:44 +0530 Subject: [PATCH] Updating to OpenVINO 2022.1 --- application/inference.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/application/inference.py b/application/inference.py index 2c3edfa..52d086a 100644 --- a/application/inference.py +++ b/application/inference.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 """ - Copyright (c) 2018 Intel Corporation. - + Copyright (c) 2022 Intel Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -9,10 +8,8 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -20,6 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + Intel® Distribution of OpenVINO™ Toolkit - OpenVINO 2022 LTS """ import os @@ -81,13 +79,11 @@ def load_model(self, model, device, input_size, output_size, num_requests, if "CPU" in device: supported_layers = self.plugin.query_network(self.net, "CPU") - not_supported_layers = \ - [l for l in self.net.layers.keys() if l not in supported_layers] - if len(not_supported_layers) != 0: + if len(supported_layers) == 0: log.error("Following layers are not supported by " "the plugin for specified device {}:\n {}". format(device, - ', '.join(not_supported_layers))) + ', '.join(supported_layers))) log.error("Please try to specify cpu extensions library path" " in command line parameters using -l " "or --cpu_extension command line argument") @@ -99,12 +95,15 @@ def load_model(self, model, device, input_size, output_size, num_requests, else: self.net_plugin = self.plugin.load_network(network=self.net, num_requests=num_requests, device_name=device, config=tag) - self.input_blob = next(iter(self.net.inputs)) - if len(self.net.inputs.keys()) == 2: + # net = ie.read_network(model=args.model) + # input_blob = next(iter(net.input_info)) + + self.input_blob = next(iter(self.net.input_info)) + if len(self.net.input_info.keys()) == 2: self.input_blob = "data" self.out_blob = next(iter(self.net.outputs)) - assert len(self.net.inputs.keys()) == input_size, \ - "Supports only {} input topologies".format(len(self.net.inputs)) + assert len(self.net.input_info.keys()) == input_size, \ + "Supports only {} input topologies".format(len(self.net.input_info)) assert len(self.net.outputs) == output_size, \ "Supports only {} output topologies".format(len(self.net.outputs)) @@ -115,7 +114,7 @@ def get_input_shape(self): Gives the shape of the input layer of the network. :return: None """ - return self.net.inputs[self.input_blob].shape + return self.net.input_info[self.input_blob].input_data.shape def performance_counter(self, request_id): """ @@ -160,10 +159,10 @@ def get_output(self, request_id, output=None): :param output: Name of the output layer :return: Results for the specified request """ - if output: - res = self.net_plugin.requests[request_id].outputs[output] - else: - res = self.net_plugin.requests[request_id].outputs[self.out_blob] + outputs = self.net_plugin.requests[request_id].output_blobs + for layer_name, out_blob in outputs.items(): + res = out_blob.buffer + return res def clean(self):