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

OpenVino support for yolov8 object detection #896

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

dhaval-zala
Copy link

I have added OpenVino for Yolov8 object detection. It will optimise the CPU usage. OpenVino allows to run model in intel CPU with less CPU consumption. This will create great impact on get_sliced_prediction in terms of cpu utilization.

@fcakyon
Copy link
Collaborator

fcakyon commented Nov 5, 2023

@dhaval-zala thank you for this great contribution! Can you please fix the conflicting file?

Copy link
Collaborator

@fcakyon fcakyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict needs to be resolved

@dhaval-zala-aivid
Copy link

@fcakyon I'll resolve it soon.

@@ -3,6 +3,7 @@
from sahi.utils.file import import_model_class

MODEL_TYPE_TO_MODEL_CLASS_NAME = {
"yolov8Vino": "Yolov8DetectionVinoModel",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"yolov8Vino": "Yolov8DetectionVinoModel",
"yolov8openvino": "Yolov8OpenvinoDetectionModel",

@@ -49,6 +50,8 @@ def __init__(
self.config_path = config_path
self.model = None
self.device = device
if ".xml" == self.model_path[-4:]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the base class, move these operations to Yolov8OpenvinoDetectionModel class

Comment on lines 63 to 64
if not ".xml" == self.model_path[-4:]:
self.set_device()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the base class, move these operations to Yolov8OpenvinoDetectionModel class

Comment on lines 4 to 5
from openvino.runtime import Core
from openvino.runtime import Core, AsyncInferQueue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be imported during function call

# self.output = None

def check_dependencies(self) -> None:
check_requirements(["ultralytics"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openvino req should be included

@@ -2,6 +2,7 @@
from os import path
from pathlib import Path
from typing import Optional
from ultralytics import YOLO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import should be moved inside to test

def download_yolov8l_model(destination_path: Optional[str] = None):
if destination_path is None:
destination_path = Yolov8TestConstants.YOLOV8L_MODEL_PATH
def OpenVino_yolov8s_model(yolov8s_model_path: Optional[str] = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def OpenVino_yolov8s_model(yolov8s_model_path: Optional[str] = None):
def download_yolov8s_openvino_model(yolov8s_model_path: Optional[str] = None):

def download_yolov8m_model(destination_path: Optional[str] = None):
if destination_path is None:
destination_path = Yolov8TestConstants.YOLOV8M_MODEL_PATH
def OpenVino_yolov8n_model(yolov8n_model_path: Optional[str] = None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def OpenVino_yolov8n_model(yolov8n_model_path: Optional[str] = None):
def download_yolov8n_openvino_model(yolov8n_model_path: Optional[str] = None):

from sahi.utils.import_utils import check_requirements


class Yolov8DetectionVinoModel(DetectionModel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Yolov8DetectionVinoModel(DetectionModel):
class Yolov8OpenvinoDetectionModel(DetectionModel):

Copy link
Author

@dhaval-zala dhaval-zala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the code. Please review it

Copy link
Collaborator

@fcakyon fcakyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the code formatting, add unit tests and a demo notebook @dhaval-zala

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.

3 participants