-
Notifications
You must be signed in to change notification settings - Fork 602
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
base: main
Are you sure you want to change the base?
OpenVino support for yolov8 object detection #896
Conversation
@dhaval-zala thank you for this great contribution! Can you please fix the conflicting file? |
There was a problem hiding this 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
@fcakyon I'll resolve it soon. |
sahi/auto_model.py
Outdated
@@ -3,6 +3,7 @@ | |||
from sahi.utils.file import import_model_class | |||
|
|||
MODEL_TYPE_TO_MODEL_CLASS_NAME = { | |||
"yolov8Vino": "Yolov8DetectionVinoModel", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"yolov8Vino": "Yolov8DetectionVinoModel", | |
"yolov8openvino": "Yolov8OpenvinoDetectionModel", |
sahi/models/base.py
Outdated
@@ -49,6 +50,8 @@ def __init__( | |||
self.config_path = config_path | |||
self.model = None | |||
self.device = device | |||
if ".xml" == self.model_path[-4:]: |
There was a problem hiding this comment.
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
sahi/models/base.py
Outdated
if not ".xml" == self.model_path[-4:]: | ||
self.set_device() |
There was a problem hiding this comment.
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
sahi/models/yolov8Vino.py
Outdated
from openvino.runtime import Core | ||
from openvino.runtime import Core, AsyncInferQueue |
There was a problem hiding this comment.
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
sahi/models/yolov8Vino.py
Outdated
# self.output = None | ||
|
||
def check_dependencies(self) -> None: | ||
check_requirements(["ultralytics"]) |
There was a problem hiding this comment.
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
sahi/utils/yolov8.py
Outdated
@@ -2,6 +2,7 @@ | |||
from os import path | |||
from pathlib import Path | |||
from typing import Optional | |||
from ultralytics import YOLO |
There was a problem hiding this comment.
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
sahi/utils/yolov8.py
Outdated
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def OpenVino_yolov8s_model(yolov8s_model_path: Optional[str] = None): | |
def download_yolov8s_openvino_model(yolov8s_model_path: Optional[str] = None): |
sahi/utils/yolov8.py
Outdated
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def OpenVino_yolov8n_model(yolov8n_model_path: Optional[str] = None): | |
def download_yolov8n_openvino_model(yolov8n_model_path: Optional[str] = None): |
sahi/models/yolov8Vino.py
Outdated
from sahi.utils.import_utils import check_requirements | ||
|
||
|
||
class Yolov8DetectionVinoModel(DetectionModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Yolov8DetectionVinoModel(DetectionModel): | |
class Yolov8OpenvinoDetectionModel(DetectionModel): |
There was a problem hiding this 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
There was a problem hiding this 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
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.