Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenVINO metadata to export #7947

Merged
merged 6 commits into from
May 24, 2022
Merged

Add OpenVINO metadata to export #7947

merged 6 commits into from
May 24, 2022

Conversation

xylieong
Copy link
Contributor

@xylieong xylieong commented May 24, 2022

Write .yaml file automatically when exporting model to openvino to be used during inference

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Improved metadata handling for OpenVINO exports and model class name loading in YOLOv5.

πŸ“Š Key Changes

  • πŸ”§ Added yaml import for metadata handling.
  • βš™οΈ Modified export_openvino function to include the model parameter.
  • ✨ OpenVINO export now saves a meta.yaml file with model stride and class names.
  • πŸ” The __init__ method in models/common.py no longer loads class names from data.yaml directly.
  • πŸ“¦ New _load_metadata method in MultiBackend class to load metadata from meta.yaml.
  • πŸ› οΈ Refactored code related to warmup to ensure GPU model warmup.

🎯 Purpose & Impact

  • πŸ”„ The changes allow for better integration and metadata management when exporting models to OpenVINO format, enabling users to retain important information about the model such as stride and class names.
  • 🧠 This improves the ease of use and compatibility of YOLOv5 models with the OpenVINO toolkit, potentially broadening the user base involved in deploying YOLOv5 on different platforms.
  • πŸƒβ€β™‚οΈ Warmup refactoring ensures that the models are correctly primed for inference, particularly on GPU devices, leading to more efficient operations post-deployment.

xylieong and others added 2 commits May 24, 2022 11:51
Write .yaml file automatically when exporting model to openvino to be used during inference
@glenn-jocher
Copy link
Member

@xylieong this is a great idea! This should be added to DetectMultiBackend() also to load these during inference.

@xylieong
Copy link
Contributor Author

@glenn-jocher Sure! Besides, I saw your commit, but would it be better that the yaml file name is based on the model name instead of 'metadata'? There might be possibility that different models exist in the same Path with different metadatas.

@glenn-jocher glenn-jocher changed the title Write .yaml file when exporting model to openvino Add OpenVINO metadata to export May 24, 2022
@glenn-jocher
Copy link
Member

@xylieong I've updated your PR and made the idea extensible to any other directory format like SavedModel and TF.js. If any of them have a meta.yaml in their directory it can now be loaded to retrieve stride and class names.

@glenn-jocher glenn-jocher merged commit a3a652c into ultralytics:master May 24, 2022
@glenn-jocher
Copy link
Member

@xylieong PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

@glenn-jocher
Copy link
Member

@glenn-jocher Sure! Besides, I saw your commit, but would it be better that the yaml file name is based on the model name instead of 'metadata'? There might be possibility that different models exist in the same Path with different metadatas.

Just saw this. Yes this is a good point. I'll make a new PR with this update.

@glenn-jocher
Copy link
Member

@xylieong resolved in #7952

@xylieong
Copy link
Contributor Author

Great!

tdhooghe pushed a commit to tdhooghe/yolov5 that referenced this pull request Jun 10, 2022
* Write .yaml file when exporting model to openvino

Write .yaml file automatically when exporting model to openvino to be used during inference

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update export.py

* Update export.py

* Load metadata on inference

* Update common.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Write .yaml file when exporting model to openvino

Write .yaml file automatically when exporting model to openvino to be used during inference

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update export.py

* Update export.py

* Load metadata on inference

* Update common.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher
Copy link
Member

@xylieong thank you! We really appreciate your feedback and suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants