feat(models): add YOLO26n mode G (unified sack+box+truck) and set active_mode to G
ci / smoke (push) Canceled after 0s

This commit is contained in:
andrew committed 2026-11-18 15:34:44 +07:00
1 parent 6d67885382
commit ba04c57334
9 files changed
+41 -12

No files matched your search

+2 -2
View File
@@ -17,7 +17,7 @@ Indonesian (`karung`=sack, `truk`=truck); YOLO class names are English
only; conf/iou/min_bbox in `models.detection_params`):
A=combined only; B=v4 truck + yolo11n sack+box; C=A + yolo11n box-only (default);
D=v4 truck + best sack-only + yolo11n box-only; E=single unified yolo11n sack+box+truck;
F=single unified yolo8n sack+box+truck (imgsz 320). New modes need no code change.
F=single unified yolo8n sack+box+truck (imgsz 320); G=single unified yolo26n sack+box+truck. New modes need no code change.
All modes load `.engine` files (2-3 coexist, ~24 MB peak); never mix load
order assumptions — PyTorch `.pt` must load before TensorRT `.engine`.
- `src/` = shared library (detection/tracking/counting/batch). `python -m src.main`
@@ -55,7 +55,7 @@ Indonesian (`karung`=sack, `truk`=truck); YOLO class names are English
`models/modelREADME.md`). Verified classes: `truck-detector`={truck},
`model_karung_truk`/`v4-best`={sack,truck}, `karung-dimuat-*-seg-200e`=
{person,sack} (seg; persons drawn, never counted), `best`={sack},
`yolo11n-…-sack+box`={sack,box}. `predict.py` auto-picks `MODEL_PATH` env, else
`yolo11n-…-sack+box`={sack,box}, `yolo26n-…-sack+box+truck`={sack,box,truck}. `predict.py` auto-picks `MODEL_PATH` env, else
`models/v4-best.engine` > `.pt` > `v4-best (1).pt` > `models/model_karung_truk.*`.
`src/config.py` defaults: `models/best.engine` (sack) / `models/truck-detector.engine`.
- **Zones**: `zones.json` is the source of truth for palet/truck/counting polygons.
+12 -1
View File
@@ -15,7 +15,7 @@ stream:
health_warn_gap_seconds: 5.0 # no processed frame for >5s = RTSP freeze/miscount-risk warning
models:
active_mode: "F" # A|B|C|D (+ future E, F, ...). Dashboard switch writes here (manual restart to apply).
active_mode: "G" # A|B|C|D (+ future E, F, G, ...). Dashboard switch writes here (manual restart to apply).
# Engine file paths (relative to repo root). Mode `engines` entries reference these keys.
paths:
@@ -25,6 +25,7 @@ models:
box: "models/yolo11n-bbox-100ep-sack+box-20260909-best.engine"
unified_bbox: "models/yolo11n-bbox-200ep-sack+box+truck-20261104-best.engine"
yolo8_unified: "models/yolo8n-bbox-100ep-sack+box+truck-imgsz320-20261110.engine"
yolo26_unified: "models/yolo26n-bbox-200ep-sack+box+truck-20261118-best.engine"
truck_detector: "models/truck-detector.engine"
# Mode presets: engines to load + class filters. NOTHING else per mode.
@@ -97,6 +98,16 @@ models:
sack: ["sack"]
box: ["box"]
G:
description: "Single unified yolo26n sack+box+truck (one engine, shared tracker/ID space)"
engines:
- path: yolo26_unified
classes: [sack, box, truck]
class_filters:
truck: ["truck"]
sack: ["sack"]
box: ["box"]
# Shared per-class detection params (ALL modes). iou default = Ultralytics default.
# min_bbox_area is a permissive guardrail in px^2 @1280x720 (existing
# perspective min_valid_area filter still applies on top).
+1
View File
@@ -8,6 +8,7 @@ MODEL_ENGINES = [
"yolo11n-bbox-100ep-sack+box-20260909-best.engine",
"yolo11n-bbox-200ep-sack+box+truck-20261104-best.engine",
"yolo8n-bbox-100ep-sack+box+truck-imgsz320-20261110.engine",
"yolo26n-bbox-200ep-sack+box+truck-20261118-best.engine",
"best.engine",
"truck-detector.engine",
"model_karung_truk.engine",
+4 -2
View File
@@ -18,6 +18,7 @@ All weights live in `models/` — full per-mode detector/filter matrix in
| `models/yolo11n-bbox-100ep-sack+box-20260909-best.{pt,onnx,engine}` | `{0: sack, 1: box}` | bbox | Unified sack+box (Modes B/C/D) |
| `models/yolo11n-bbox-200ep-sack+box+truck-20261104-best.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Unified sack+box+truck (Mode E) |
| `models/yolo8n-bbox-100ep-sack+box+truck-imgsz320-20261110.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Unified sack+box+truck, imgsz 320 (Mode F) |
| `models/yolo26n-bbox-200ep-sack+box+truck-20261118-best.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Unified sack+box+truck (Mode G) |
| `models/best.{pt,onnx,engine}` | `{0: sack}` | seg | Sack-only specialist (Mode D sack; `src/config.py` default) |
Model registry for the `rpo_iki` engine: `rpo_iki/configs/model_registry.json`
@@ -57,10 +58,11 @@ Two dedicated models run in parallel on the same frames:
| C (default) | v4 (sack+truck) | v4 | yolo11n (box-only) | | D | v4 (truck-only) | best (sack-only) | yolo11n (box-only) |
| E | unified yolo11n (imgsz 640) | same handle | same handle |
| F | unified yolo8n (imgsz 320) | same handle | same handle |
| G | unified yolo26n (imgsz 640) | same handle | same handle |
- Mode E/F are **single unified** handles (one engine, one tracker, one track-ID
- Mode E/F/G are **single unified** handles (one engine, one tracker, one track-ID
space for sack+box+truck). Mode F uses the yolo8n handle at imgsz 320 → higher
risk of missing small sacks than E (640); A/B count comparison on the same
risk of missing small sacks than E/G (640); A/B count comparison on the same
clip is still open.
- `models.active_mode` (config.yaml) selects the mode; the dashboard writes it,
a service restart applies it.
+3
View File
@@ -17,6 +17,7 @@ Class names below are read directly from each checkpoint (`YOLO(path).names`).
| `yolo11n-bbox-100ep-sack+box-20260909-best.{pt,onnx,engine}` | `{0: sack, 1: box}` | bbox | Unified sack+box (Modes B/C/D) |
| `yolo11n-bbox-200ep-sack+box+truck-20261104-best.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Single unified sack+box+truck (Mode E) |
| `yolo8n-bbox-100ep-sack+box+truck-imgsz320-20261110.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Single unified sack+box+truck, **imgsz 320** (Mode F) |
| `yolo26n-bbox-200ep-sack+box+truck-20261118-best.{pt,onnx,engine}` | `{0: sack, 1: box, 2: truck}` | bbox | Single unified sack+box+truck (Mode G) |
| `best.{pt,onnx,engine}` | `{0: sack}` | seg | Sack-only specialist (Mode D sack) |
| `karung-dimuat-detection-di-feedmill-yolo26n-seg-200e.{pt,onnx,engine}` | `{0: person, 1: sack}` | **seg** | Person-exclusion seg model (legacy `predict_new.py`) |
@@ -41,12 +42,14 @@ dropped before tracking/counting.
| **D** | `v4-best.engine` → keep `truck`, drop `sack` | `best.engine` → `sack` only (nothing to drop) | `yolo11n-….engine` → keep `box`, drop `sack` |
| **E** | `yolo11n-bbox-200ep-sack+box+truck-….engine` → keep `truck` | same handle → keep `sack`, drop `truck` | same handle → keep `box`, drop `sack` |
| **F** | `yolo8n-bbox-100ep-sack+box+truck-imgsz320-….engine` → keep `truck` | same handle → keep `sack`, drop `truck` | same handle → keep `box`, drop `sack` |
| **G** | `yolo26n-bbox-200ep-sack+box+truck-….engine` → keep `truck` | same handle → keep `sack`, drop `truck` | same handle → keep `box`, drop `sack` |
Notes:
- Mode B loads **one** yolo11n handle shared by the sack and box paths (single
tracker, single track-ID space); modes C/D run a dedicated box tracker
- Mode E loads **one** unified yolo11n handle covering sack/box/truck (single tracker, single track-ID space; no separate truck model or box tracker).
- Mode F = same layout as E but with the **yolo8n** handle at **imgsz 320** (one engine, one tracker, classes sack/box/truck). Smaller input than E (640) → higher risk of missing small sacks; A/B count comparison against E on the same clip is still open.
- Mode G loads **one** unified yolo26n handle covering sack/box/truck at imgsz 640 (single tracker, single track-ID space; no separate truck model or box tracker).
(separate ID space + own stabilizer, so sack/box IDs never collide).
- All `.engine` files verified to coexist: 2 engines ~16 MB, 3 engines ~24 MB
peak of 7.6 GB Jetson GPU. If `.pt` is ever used, load PyTorch models **before**
+3 -2
View File
@@ -89,7 +89,8 @@ def parse_args():
"A=combined only; B=v4 truck + yolo11n sack+box; "
"C=A + yolo11n box-only; D=v4 truck + best sack + yolo11n box; "
"E=single unified yolo11n sack+box+truck; "
"F=single unified yolo8n sack+box+truck (imgsz 320). "
"F=single unified yolo8n sack+box+truck (imgsz 320); "
"G=single unified yolo26n sack+box+truck. "
"New modes from config.yaml need no code change.")
p.add_argument("--config", type=str, default=None,
help="Path to config.yaml (default: config.yaml next to predict.py)")
@@ -350,7 +351,7 @@ def apply_cli_overrides_to_config(cfg: Config, args) -> Config:
# Modes are DATA in config.yaml models.modes (engines + class filters only).
# A=combined only; B=v4 truck + yolo11n sack+box; C=A + yolo11n box-only (default);
# D=v4 truck + best sack-only + yolo11n box-only; E=single unified yolo11n sack+box+truck;
# F=single unified yolo8n sack+box+truck (imgsz 320). New modes need no code change.
# F=single unified yolo8n sack+box+truck (imgsz 320); G=single unified yolo26n sack+box+truck. New modes need no code change.
# All engines verified to coexist (~16-24 MB peak of 7.6 GB).
+16 -5
View File
@@ -25,7 +25,7 @@ def repo_config_path():
def test_repo_config_loads_and_validates(repo_config_path):
cfg = load_config(repo_config_path)
assert cfg.models.active_mode == "E"
assert cfg.models.active_mode == "G"
assert set(cfg.models.modes) >= {"A", "B", "C", "D"}
for mode_id, mode in cfg.models.modes.items():
assert mode.engines, f"mode {mode_id} has no engines"
@@ -50,6 +50,17 @@ def test_mode_f_is_config_only_yolo8(repo_config_path):
assert mode.class_filters == {"truck": ["truck"], "sack": ["sack"], "box": ["box"]}
def test_mode_g_is_config_only_yolo26(repo_config_path):
cfg = load_config(repo_config_path)
assert "G" in cfg.models.modes
mode = cfg.models.modes["G"]
assert len(mode.engines) == 1
eng = mode.engines[0]
assert eng.classes == ["sack", "box", "truck"]
assert "yolo26" in cfg.models.paths[eng.path]
assert mode.class_filters == {"truck": ["truck"], "sack": ["sack"], "box": ["box"]}
def test_do_block_and_batch_default_mode(repo_config_path):
cfg = load_config(repo_config_path)
assert cfg.batch.default_mode == "manual"
@@ -123,10 +134,10 @@ def test_mode_preset_only_filters_and_engines(repo_config_path):
def test_resolve_active_mode_precedence(repo_config_path, monkeypatch):
cfg = load_config(repo_config_path)
monkeypatch.delenv("MODEL_MODE", raising=False)
assert resolve_active_mode(None, cfg) == "E"
assert resolve_active_mode(None, cfg) == "G"
assert resolve_active_mode("d", cfg) == "D"
with pytest.warns(UserWarning): # unknown -> fallback to active
assert resolve_active_mode("Z", cfg) == "E"
assert resolve_active_mode("Z", cfg) == "G"
monkeypatch.setenv("MODEL_MODE", "B")
with pytest.warns(DeprecationWarning): # env still honoured, deprecated
assert resolve_active_mode(None, cfg) == "B"
@@ -180,8 +191,8 @@ def test_legacy_batch_mode_check(tmp_path, repo_config_path):
legacy = tmp_path / "batch_mode.json"
legacy.write_text(json.dumps({"mode": "auto", "model_mode": "B"}))
msg = check_legacy_batch_mode(cfg, legacy)
assert msg is not None and "'B'" in msg and "'E'" in msg
legacy.write_text(json.dumps({"mode": "auto", "model_mode": "E"}))
assert msg is not None and "'B'" in msg and "'G'" in msg
legacy.write_text(json.dumps({"mode": "auto", "model_mode": "G"}))
assert check_legacy_batch_mode(cfg, legacy) is None
assert check_legacy_batch_mode(cfg, tmp_path / "missing.json") is None