From 0821ccb618e83e7f127cd51f5dfff16c8f771151 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 12 Jul 2023 20:48:11 +0200 Subject: [PATCH] Changed default device to AUTO in OpenVINO (#3699) Co-authored-by: Glenn Jocher --- ultralytics/nn/autobackend.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ultralytics/nn/autobackend.py b/ultralytics/nn/autobackend.py index 01e335b..7e713dd 100644 --- a/ultralytics/nn/autobackend.py +++ b/ultralytics/nn/autobackend.py @@ -137,17 +137,17 @@ class AutoBackend(nn.Module): LOGGER.info(f'Loading {w} for OpenVINO inference...') check_requirements('openvino') # requires openvino-dev: https://pypi.org/project/openvino-dev/ from openvino.runtime import Core, Layout, get_batch # noqa - ie = Core() + core = Core() w = Path(w) if not w.is_file(): # if not *.xml w = next(w.glob('*.xml')) # get *.xml file from *_openvino_model dir - network = ie.read_model(model=str(w), weights=w.with_suffix('.bin')) - if network.get_parameters()[0].get_layout().empty: - network.get_parameters()[0].set_layout(Layout('NCHW')) - batch_dim = get_batch(network) + ov_model = core.read_model(model=str(w), weights=w.with_suffix('.bin')) + if ov_model.get_parameters()[0].get_layout().empty: + ov_model.get_parameters()[0].set_layout(Layout('NCHW')) + batch_dim = get_batch(ov_model) if batch_dim.is_static: batch_size = batch_dim.get_length() - executable_network = ie.compile_model(network, device_name='CPU') # device_name="MYRIAD" for NCS2 + ov_compiled_model = core.compile_model(ov_model, device_name='AUTO') # AUTO selects best available device metadata = w.parent / 'metadata.yaml' elif engine: # TensorRT LOGGER.info(f'Loading {w} for TensorRT inference...') @@ -339,7 +339,7 @@ class AutoBackend(nn.Module): y = self.session.run(self.output_names, {self.session.get_inputs()[0].name: im}) elif self.xml: # OpenVINO im = im.cpu().numpy() # FP32 - y = list(self.executable_network([im]).values()) + y = list(self.ov_compiled_model([im]).values()) elif self.engine: # TensorRT if self.dynamic and im.shape != self.bindings['images'].shape: i = self.model.get_binding_index('images')