Last active
October 5, 2019 06:17
-
-
Save avirup171/b95d8f9b8f19797167412aa20c0f58c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialise_inference(self): | |
model_xml=self.model | |
model_bin = os.path.splitext(model_xml)[0] + ".bin" | |
# Plugin initialization for specified device and load extensions library if specified | |
log.info("Initializing plugin for {} device...".format(self.device)) | |
plugin = IEPlugin(device=self.device, plugin_dirs=self.plugin_dir) | |
if self.cpu_extension and 'CPU' in self.device: | |
log.info("Loading plugins for {} device...".format(self.device)) | |
plugin.add_cpu_extension(self.cpu_extension) | |
# Read IR | |
log.info("Reading IR...") | |
net = IENetwork(model=model_xml, weights=model_bin) | |
if plugin.device == "CPU": | |
supported_layers = plugin.get_supported_layers(net) | |
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers] | |
if len(not_supported_layers) != 0: | |
log.error("Following layers are not supported by the plugin for specified device {}:\n {}". | |
format(plugin.device, ', '.join(not_supported_layers))) | |
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l " | |
"or --cpu_extension command line argument") | |
sys.exit(1) | |
assert len(net.inputs.keys()) == 1, "Sample supports only single input topologies" | |
assert len(net.outputs) == 1, "Sample supports only single output topologies" | |
input_blob = next(iter(net.inputs)) | |
out_blob = next(iter(net.outputs)) | |
log.info("Loading IR to the plugin...") | |
exec_net = plugin.load(network=net, num_requests=2) | |
if isinstance(net.inputs[input_blob], list): | |
n, c, h, w = net.inputs[input_blob] | |
else: | |
n, c, h, w = net.inputs[input_blob].shape | |
del net | |
processor= Processor(exec_net,input_blob,out_blob,n,c,h,w) | |
return processor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment