Properly expose batch_size from OpenVINO similarly to TensorRT (#8514)
Properly expose `batch_size` from OpenVINO Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
f17444abcd
commit
be42a24d23
1 file changed
+6
-1
+6
-1
@@ -361,11 +361,16 @@ class DetectMultiBackend(nn.Module):
|
||||
elif xml: # OpenVINO
|
||||
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
|
||||
from openvino.runtime import Core, Layout, get_batch
|
||||
ie = Core()
|
||||
if not Path(w).is_file(): # if not *.xml
|
||||
w = next(Path(w).glob('*.xml')) # get *.xml file from *_openvino_model dir
|
||||
network = ie.read_model(model=w, weights=Path(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)
|
||||
if batch_dim.is_static:
|
||||
batch_size = batch_dim.get_length()
|
||||
executable_network = ie.compile_model(network, device_name="CPU") # device_name="MYRIAD" for Intel NCS2
|
||||
output_layer = next(iter(executable_network.outputs))
|
||||
meta = Path(w).with_suffix('.yaml')
|
||||
|
||||
Reference in new issue
Block a user