Instructions to use mayanktak15/yolo8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use mayanktak15/yolo8 with ultralytics:
# Couldn't find a valid YOLO version tag. # Replace XX with the correct version. from ultralytics import YOLOvXX model = YOLOvXX.from_pretrained("mayanktak15/yolo8") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
| """Reusable detector abstractions.""" | |
| from __future__ import annotations | |
| from abc import ABC, abstractmethod | |
| from dataclasses import dataclass | |
| from typing import Sequence | |
| import numpy as np | |
| BBox = tuple[float, float, float, float] | |
| class Detection: | |
| """Single object detection emitted by a detector.""" | |
| class_name: str | |
| confidence: float | |
| bbox: BBox | |
| class_id: int | None = None | |
| def as_dict(self) -> dict[str, object]: | |
| return { | |
| "class": self.class_name, | |
| "confidence": round(float(self.confidence), 4), | |
| "bbox": [round(float(v), 2) for v in self.bbox], | |
| "class_id": self.class_id, | |
| } | |
| class BaseDetector(ABC): | |
| """Contract for frame-level object detectors.""" | |
| def detect(self, frame: np.ndarray) -> Sequence[Detection]: | |
| """Return detections for one BGR video frame.""" | |