Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Updating to OpenVINO 2022.1 #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions application/inference.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#!/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
without limitation the rights to use, copy, modify, merge, publish,
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
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
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
Expand Down Expand Up @@ -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")
Expand All @@ -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))

Expand All @@ -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):
"""
Expand Down Expand Up @@ -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):
Expand Down