1 ADR 0051 upgrade yolo to medium
Forgejo Actions edited this page 2026-09-25 16:38:07 +00:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

ADR 0051: Upgrade YOLO-World model from 's' to 'm'

Status: accepted Date: 2026-06-13

Decision

Upgrade the YOLO-World model used for plant detection from yolov8s-worldv2 (small, 12.7M params) to yolov8m-worldv2 (medium, 25M params).

Rationale

The current small model produces imprecise bounding boxes — detections often cover the full image frame even when the plant is localized in a small region. This is because the 's' feature map has a coarse grid (~20×26 cells for 480×640 input). Each cell covers ~24×24 pixels, limiting boundary precision.

Upgrading to 'm' provides:

  • Higher-resolution feature maps → finer grid → tighter bounding boxes
  • More capacity to distinguish plant boundary from background
  • No architectural changes needed — same YOLO-World pipeline, same ONNX runtime

For a self-hosted family server, 'm' is the sweet spot (see trade-offs below). 'l' and 'x' offer diminishing returns on CPU inference.

Trade-offs

  • ONNX model: ~49 MB → ~80 MB (acceptable for Docker images)
  • CPU inference: 50-100ms → 100-200ms per image (still fast in batch)
  • RAM during inference: ~500 MB → ~800 MB (fine for typical 8+ GB servers)
  • GPU not required — ONNX runtime CPU-bound inference is adequate

Model Source

YOLOv8m-worldv2 ONNX weights are available from Ultralytics: https://github.com/ultralytics/ultralytics

Download via:

from ultralytics import YOLO
model = YOLO("yolov8m-worldv2.pt")
model.export(format="onnx", dynamic=True)

Implementation

  • Replace /app/models/yolo/model.onnx with the 'm' variant
  • Update Dockerfile or build process to download the 'm' model
  • No code changes needed — same interface (ONNX, same input shape, same output format)

Future

  • If 'm' still produces overly large boxes on dense plant scenes, consider SAHI (tiled inference) as a separate improvement
  • 'l' is a future option if CPU performance improves (newer hardware) or GPU becomes available