Skip to main content

🚀 acmenra-yolo

Official Ultralytics YOLO backend plugin for acmenra-cv

PyPI Python License

# Install the YOLO plugin (automatically pulls acmenra-cv >= 0.3.0.0)
pip install acmenra-yolo

📦 Overview

acmenra-yolo is an official plugin package for acmenra-cv that provides seamless integration with Ultralytics YOLO models. It extends the core framework with a concrete Backend implementation, enabling object detection, instance segmentation, and oriented bounding box (OBB) tasks using state-of-the-art YOLO architectures (v8/v11).

This package is part of the modular acmenra-cv ecosystem, designed to keep the core framework lightweight. By separating YOLO support into a dedicated package, users who work with custom models or other inference engines (OpenVINO, TensorRT, etc.) can avoid pulling in heavy dependencies like ultralytics and torch.

Feature Description
Full Task Support Detection, segmentation, and OBB in a single unified backend.
Native Tracking Leverages YOLO's built-in BoT-SORT tracker for persistent object IDs.
High-Quality Masks Optional refined mode for smoother segmentation boundaries (retina_masks).
Timing Metrics Extracts preprocess, prediction, and postprocess timings from YOLO's speed dictionary.
Hardware Acceleration Supports CPU, CUDA, MPS, TensorRT, and more via DeviceType enum.
Seamless Integration Returns standard acmenra_cv.Result containers, fully compatible with Tracker and Drawer.

✨ Key Features

🔹 Unified YOLO Integration

  • Backend-Agnostic Contract: Implements the acmenra_cv.Backend interface perfectly.
  • Strict Validation: All parameters (iou, imgsz, half, refined) are strictly typed and range-validated via property setters.
  • Automatic Task Routing: Intelligently processes boxes, masks, or obb outputs based on the model's task type.

🔹 Performance & Quality

  • Refined Mask Generation: Toggle refined=True to generate masks at full model resolution for smoother boundaries (at a ~20-30% speed cost).
  • Zero-Crash Design: Inherits robust frame validation and graceful degradation from the core acmenra-cv architecture.
  • Optimized Conversions: Direct, vectorized conversion from YOLO tensors to normalized acmenra_cv spatial primitives (Box, Polygon, Obb).

🔹 ADAS & Tracking Ready

  • Persistent IDs: Native support for YOLO's tracking mode (track=True) for multi-object tracking across frames.
  • Temporal Consistency: Outputs are immediately compatible with acmenra_cv.Tracker for trajectory smoothing and zone analysis.

💡 Quick Start

from enum import Enum
import numpy as np

# 1. Import core components and the YOLO plugin
from acmenra_cv import DeviceType, TaskType, Tracker
from acmenra_yolo import YOLOBackend
from ultralytics import YOLO

# 2. Define your categories
class CocoClass(Enum):
    PERSON = 0
    CAR = 2

# 3. Initialize the YOLO model
model = YOLO("yolov8n-seg.pt")

# 4. Create the backend-agnostic inference engine
backend = YOLOBackend(
    model=model,
    device=DeviceType.MPS,       # or CPU, CUDA_0, TENSORRT, etc.
    category=CocoClass,          # Enum CLASS for label mapping
    task_type=TaskType.SEGMENT,
    threshold=0.35,
    iou=0.7,
    imgsz=640,
    half=False,
    refined=True                 # Enable high-quality mask generation
)

# 5. Use with Tracker (decoupled inference and tracking logic)
tracker = Tracker(id=0, backend=backend, max_length=30)

# 6. Process a frame
frame = np.zeros((1080, 1920, 3), dtype=np.uint8)  # Replace with your BGR frame
tracked_objects = tracker.track(frame, enable_tracking=True)

# 7. Access results
for obj in tracked_objects:
    print(f"ID: {obj.id}, Class: {obj.instance.label.name}, Conf: {obj.instance.conf:.2f}")
    # Access spatial data: obj.instance.box, obj.instance.polygon, obj.instance.obb

🧩 API Documentation

🔷 acmenra_yolo / yolo_backend.py

class YOLOBackend - YOLO-specific inference backend using Ultralytics YOLO models.

Concrete implementation of the acmenra_cv.Backend contract for YOLO models. Handles detection, segmentation, and OBB tasks with optimized processing for YOLO's output format.

⚙️ Properties (Strictly Validated)

  • 🟢 model: YOLO - Gets/sets the Ultralytics YOLO model instance. Triggers state refresh on change.
  • 🟢 iou: float - IoU threshold for NMS [0.0, 1.0].
  • 🟢 imgsz: int - Inference image size in pixels (must be > 0, ideally multiple of 32).
  • 🟢 half: bool - FP16 inference flag (CUDA only).
  • 🟢 refined: bool - High-quality mask generation flag (maps to retina_masks).

🚀 Methods

  • 🔴 predict(): Result - Performs YOLO inference and converts results to normalized Instance objects. Supports detection, segmentation, and OBB modes. Accepts max_det, track, and verbose parameters. Automatically applies retina_masks based on self.refined. Needs tests.
  • 🔴 _process_bbox_results(): List[Instance] - Private method processing YOLO bounding box results into Instance objects. Needs tests.
  • 🔴 _process_obb_results(): List[Instance] - Private method processing YOLO OBB results into Instance objects with normalized coordinates. Needs tests.
  • 🔴 _process_seg_results(): List[Instance] - Private method processing YOLO segmentation results into Instance objects with polygon masks. Needs tests.
  • 🔴 normalize_xywhr(): list[float] - Static method explicitly normalizing [cx, cy, w, h, angle_rad] from pixels to [0.0, 1.0]. Angle remains in radians.


📋 Requirements

Core dependencies (automatically installed):

acmenra-cv>=0.3.0.0
ultralytics>=8.0.0
torch>=1.8.0
opencv-python>=4.5.0

Development dependencies:

pytest>=7.0.0
black>=23.0.0
mypy>=1.0.0

🧪 Testing

The plugin includes comprehensive test suites with DDT (Data-Driven Testing) and extensive mocks to avoid downloading real weights during CI/CD:

# Run all plugin tests
pytest tests/

# Run specific backend tests
pytest tests/inference/backends/

Test coverage includes:

  • ✅ Type validation (positive and negative paths for all properties)
  • ✅ Range validation (boundary conditions for iou, imgsz, etc.)
  • ✅ Edge cases (empty detections, OBB without tracking, extreme resolutions)
  • ✅ Seamless integration with acmenra_cv.Result and acmenra_cv.Tracker

🔐 License

This project is licensed under the GNU Affero General Public License v3 or later (AGPL-3.0-or-later), matching the core acmenra-cv framework.
See the LICENSE file for details.


🌐 Links


acmenra.studio — Building reliable vision systems for the edge.
Every millisecond and frame buffer counts. 🚀

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acmenra_yolo-0.1.0.0.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acmenra_yolo-0.1.0.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file acmenra_yolo-0.1.0.0.tar.gz.

File metadata

  • Download URL: acmenra_yolo-0.1.0.0.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for acmenra_yolo-0.1.0.0.tar.gz
Algorithm Hash digest
SHA256 517846963108ea951853e1394dbf9ed3a73ced57e4170c9aa5243e2342b52959
MD5 1f5309dfb17d4385c0f0f82d9f2ac262
BLAKE2b-256 1c0c3de46b361ab2b57886b053009a9c65cef48011676e5b0dfed4ba667ee634

See more details on using hashes here.

File details

Details for the file acmenra_yolo-0.1.0.0-py3-none-any.whl.

File metadata

  • Download URL: acmenra_yolo-0.1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for acmenra_yolo-0.1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 848f6b1934cb84fee04639d79687d2bb1589c39010f2c0dd5f66c2a441c130b7
MD5 fb4dd8ccf57f8facd19111494faa4a7d
BLAKE2b-256 29fae302040775cea7a843723956e8f67f503213722d92bd183a6587f452f65b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page