| 187 | |
| 188 | @try_export |
| 189 | def export_openvino(file, metadata, half, prefix=colorstr('OpenVINO:')): |
| 190 | # YOLOv5 OpenVINO export |
| 191 | check_requirements('openvino-dev') # requires openvino-dev: https://pypi.org/project/openvino-dev/ |
| 192 | import openvino.inference_engine as ie |
| 193 | |
| 194 | LOGGER.info(f'\n{prefix} starting export with openvino {ie.__version__}...') |
| 195 | f = str(file).replace('.pt', f'_openvino_model{os.sep}') |
| 196 | |
| 197 | cmd = f"mo --input_model {file.with_suffix('.onnx')} --output_dir {f} --data_type {'FP16' if half else 'FP32'}" |
| 198 | subprocess.run(cmd.split(), check=True, env=os.environ) # export |
| 199 | yaml_save(Path(f) / file.with_suffix('.yaml').name, metadata) # add metadata.yaml |
| 200 | return f, None |
| 201 | |
| 202 | |
| 203 | @try_export |