xylieong glenn-jocher commited on
Commit
27911dc
1 Parent(s): 0dd66e2

OpenVINO metadata fix2 (#7954)

Browse files

* Bug Fixed: OpenVINO metadata

* Bug Fixed: OpenVINO metadata

* Update export.py

* Update export.py

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Files changed (2) hide show
  1. export.py +1 -1
  2. models/common.py +1 -1
export.py CHANGED
@@ -180,7 +180,7 @@ def export_openvino(model, file, half, prefix=colorstr('OpenVINO:')):
180
 
181
  cmd = f"mo --input_model {file.with_suffix('.onnx')} --output_dir {f} --data_type {'FP16' if half else 'FP32'}"
182
  subprocess.check_output(cmd.split()) # export
183
- with open(Path(f) / file.with_suffix('.yaml'), 'w') as g:
184
  yaml.dump({'stride': int(max(model.stride)), 'names': model.names}, g) # add metadata.yaml
185
 
186
  LOGGER.info(f'{prefix} export success, saved as {f} ({file_size(f):.1f} MB)')
 
180
 
181
  cmd = f"mo --input_model {file.with_suffix('.onnx')} --output_dir {f} --data_type {'FP16' if half else 'FP32'}"
182
  subprocess.check_output(cmd.split()) # export
183
+ with open(Path(f) / file.with_suffix('.yaml').name, 'w') as g:
184
  yaml.dump({'stride': int(max(model.stride)), 'names': model.names}, g) # add metadata.yaml
185
 
186
  LOGGER.info(f'{prefix} export success, saved as {f} ({file_size(f):.1f} MB)')
models/common.py CHANGED
@@ -368,7 +368,7 @@ class DetectMultiBackend(nn.Module):
368
  network = ie.read_model(model=w, weights=Path(w).with_suffix('.bin'))
369
  executable_network = ie.compile_model(model=network, device_name="CPU")
370
  output_layer = next(iter(executable_network.outputs))
371
- meta = w.with_suffix('.yaml')
372
  if meta.exists():
373
  stride, names = self._load_metadata(meta) # load metadata
374
  elif engine: # TensorRT
 
368
  network = ie.read_model(model=w, weights=Path(w).with_suffix('.bin'))
369
  executable_network = ie.compile_model(model=network, device_name="CPU")
370
  output_layer = next(iter(executable_network.outputs))
371
+ meta = Path(w).with_suffix('.yaml')
372
  if meta.exists():
373
  stride, names = self._load_metadata(meta) # load metadata
374
  elif engine: # TensorRT