Skip to content

Commit

Permalink
Update yolov8_sahi.py (ultralytics#15470)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <[email protected]>
  • Loading branch information
glenn-jocher and UltralyticsAssistant authored Aug 13, 2024
1 parent 265166a commit d7d3449
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/YOLOv8-SAHI-Inference-Video/yolov8_sahi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
from ultralytics.utils.plotting import Annotator, colors


class SahiInference:
class SAHIInference:
"""Runs YOLOv8 and SAHI for object detection on video with options to view, save, and track results."""

def __init__(self):
"""Initializes the SAHIInference class for performing sliced inference using SAHI with YOLOv8 models."""
self.detection_model = None

def load_model(self, weights):
"""Loads a YOLOv8 model with specified weights for object detection using SAHI."""
yolov8_model_path = f"models/{weights}"
download_yolov8s_model(yolov8_model_path)
self.detection_model = AutoDetectionModel.from_pretrained(
Expand Down Expand Up @@ -98,5 +102,5 @@ def parse_opt(self):


if __name__ == "__main__":
inference = SahiInference()
inference = SAHIInference()
inference.inference(**vars(inference.parse_opt()))

0 comments on commit d7d3449

Please sign in to comment.