Skip to content

feat: add LibreYOLO as detection model backend - #1425

Open
IIIllllIlIlllII wants to merge 4 commits into
obss:mainfrom
IIIllllIlIlllII:feat/add-libreyolo-support
Open

feat: add LibreYOLO as detection model backend#1425
IIIllllIlIlllII wants to merge 4 commits into
obss:mainfrom
IIIllllIlIlllII:feat/add-libreyolo-support

Conversation

@IIIllllIlIlllII

Copy link
Copy Markdown

Summary

Adds LibreYOLO as a new detection model backend, as requested in #1397.

LibreYOLO is an MIT-licensed computer vision library with an API compatible with Ultralytics (same Results, Boxes, Masks, OBB interfaces). The implementation inherits from UltralyticsDetectionModel with four overrides to adapt for LibreYOLO's differences:

  • check_dependencies() — requires libreyolo instead of ultralytics
  • load_model() — uses LibreYOLO() factory (device is passed at construction, not via .to())
  • perform_batch_inference() — removes the cfg kwarg that LibreYOLO doesn't support
  • _extract_predictions() — imports Masks from libreyolo instead of ultralytics

Usage

from sahi import AutoDetectionModel, get_sliced_prediction

detection_model = AutoDetectionModel.from_pretrained(
    model_type="libreyolo",
    model_path="LibreYOLO9t.pt",
    confidence_threshold=0.3,
    device="cpu",
)

result = get_sliced_prediction(
    "image.jpg",
    detection_model,
    slice_height=640,
    slice_width=640,
)

Changes

File Description
sahi/models/libreyolo.py New — model class inheriting from UltralyticsDetectionModel
sahi/auto_model.py +1 line — register "libreyolo" model type
sahi/utils/libreyolo.py New — test constants and model download helper
tests/test_libreyolo_model.py New — 5 tests (load, set_model, inference, convert, auto_model)

Tests

All 5 tests pass:

tests/test_libreyolo_model.py::test_load_model PASSED
tests/test_libreyolo_model.py::test_set_model PASSED
tests/test_libreyolo_model.py::test_perform_inference PASSED
tests/test_libreyolo_model.py::test_convert_original_predictions PASSED
tests/test_libreyolo_model.py::test_auto_model_type PASSED

Why LibreYOLO?

LibreYOLO provides MIT-licensed YOLO inference (vs Ultralytics' AGPL), which matters for users building commercial or closed-source applications. It supports YOLOv9, RF-DETR, YOLOX, and other architectures behind a single LibreYOLO() factory.

IIIllllIlIlllII and others added 4 commits August 17, 2026 09:50
Add LibreYOLO (MIT-licensed) support as a new model type.
LibreYOLO's API is compatible with Ultralytics, so the
implementation inherits from UltralyticsDetectionModel and
overrides load_model(), check_dependencies(),
perform_batch_inference(), and _extract_predictions().

Resolves discussion obss#1397
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.

1 participant