Commit Graph
4 Commits
Author SHA1 Message Date
Arnaud Dartois 64a769c7de fix(agent): bound inference work and drain ONNX before disposal 2026-10-20 02:25:27 +02:00
Arnaud Dartois 4b3068e12f feat(agent): align FrameAnalyzerService with spec §16 — IntraOpNumThreads, MinConfidence, model path (#169) 2026-08-27 00:36:03 +02:00
Arnaud Dartois 2fe48f0865 feat(agent): implement real YOLO/ONNX inference in FrameAnalyzerService (#148)
## What
Replace the stub `FrameAnalyzerService.RunInference` (returning `[]`) with a real ONNX Runtime inference pipeline for YOLOv8 object detection.

## Why
The entire detection chain was non-functional — `FrameAnalyzerService` returned empty results, `Microsoft.ML.OnnxRuntime` was not referenced, and no object detection was produced. This is the core AI feature of the Heimdall platform (issue #2, etape-3).

## How
- **Packages**: Added `Microsoft.ML.OnnxRuntime` 1.22.0 and `SixLabors.ImageSharp` 4.1.0 to `Heimdall.Agent.csproj`
- **ONNX session**: `InferenceSession` loaded in constructor with graceful fallback to passthrough mode when model is absent
- **Preprocessing**: JPEG → ImageSharp `Image<Rgb24>` → resize 640×640 → NCHW tensor normalized [0,1]
- **Inference**: ONNX Runtime `Session.Run()` with the preprocessed tensor
- **Post-processing**: YOLOv8 output parsing (`[1, 4+C, 8400]` tensor → bounding boxes + class scores) with class-aware Non-Maximum Suppression (IoU threshold 0.45, confidence threshold 0.25)
- **Tests**: 13 new unit tests for NMS logic, output parsing, bounding box conversion, and COCO class mapping (206 Agent tests total, all green)

## Testing
- `dotnet build` — 0 errors (TreatWarningsAsErrors=true)
- `dotnet test --filter "FullyQualifiedName!~E2E"` — 1282 passed, 0 failed
- E2E failures are pre-existing (Playwright/Chromium not installed on this runner)

## Notes
- Model path configurable via `MODEL_PATH` env var (default: `models/yolov8m.onnx`)
- Passthrough mode preserved when model file is absent — no crash
- Thread-safe: `InferenceSession.Run()` is thread-safe; session created once in constructor

Reviewed-on: https://forgejo.tordais.cc/nonobis/Heimdall/pulls/148
2026-08-19 23:06:06 +02:00
Arnaud Dartois 262adc07cf test(agent): add service tests for CameraStream, ConfigReceiver, FrameAnalyzer, SystemMetrics, DTOs 2026-07-23 15:37:20 +00:00