From 01273c5ca1ecb50cc6f3f8dcc6b2434c61ecbd65 Mon Sep 17 00:00:00 2001 From: Zlobin Vladimir Date: Tue, 6 Jun 2023 02:29:12 +0400 Subject: [PATCH] Add rt info for OpenVINO ModelAPI (#2891) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher Co-authored-by: Ayush Chaurasia --- ultralytics/yolo/engine/exporter.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ultralytics/yolo/engine/exporter.py b/ultralytics/yolo/engine/exporter.py index 2f2bd5d..d63c22c 100644 --- a/ultralytics/yolo/engine/exporter.py +++ b/ultralytics/yolo/engine/exporter.py @@ -362,6 +362,18 @@ class Exporter: model_name=self.pretty_name, framework='onnx', compress_to_fp16=self.args.half) # export + + # Set RT info + ov_model.set_rt_info('YOLOv8', ['model_info', 'model_type']) + ov_model.set_rt_info(True, ['model_info', 'reverse_input_channels']) + ov_model.set_rt_info(114, ['model_info', 'pad_value']) + ov_model.set_rt_info([255.0], ['model_info', 'scale_values']) + ov_model.set_rt_info(self.args.iou, ['model_info', 'iou_threshold']) + ov_model.set_rt_info([v.replace(' ', '_') for k, v in sorted(self.model.names.items())], + ['model_info', 'labels']) + if self.model.task != 'classify': + ov_model.set_rt_info('fit_to_window_letterbox', ['model_info', 'resize_type']) + ov.serialize(ov_model, f_ov) # save yaml_save(Path(f) / 'metadata.yaml', self.metadata) # add metadata.yaml return f, None