edgefirst-decoder
High-performance ML model output decoding for object detection and segmentation.
This crate provides efficient post-processing for YOLO and ModelPack model outputs, supporting both floating-point and quantized inference results.
Supported Models
| Family | Detection | Segmentation | Formats |
|---|---|---|---|
| YOLO | YOLOv5, v8, v11, v26 | Instance seg | float32, int8, uint8 |
| ModelPack | SSD-style | Semantic seg | float32, int8, uint8 |
Features
- Quantized decoding - Direct int8/uint8 processing without dequantization overhead
- Configurable NMS - Class-agnostic or class-aware non-maximum suppression
- Batch processing - Efficient handling of batched model outputs
- Builder pattern - Flexible configuration with sensible defaults
Quick Start
use ;
// Build decoder from model config
let decoder = new
.with_score_threshold
.with_iou_threshold
.with_config_json_str
.build?;
// Decode quantized model output
let mut detections: = Vecwith_capacity;
let mut masks: = Vecwith_capacity;
decoder.decode_quantized?;
// Process results
for det in &detections
Low-Level API
For known model types, use the direct decoding functions:
use decode_yolo_det;
use Quantization;
let mut detections = Vecwith_capacity;
decode_yolo_det;
Configuration
Decoders can be configured via JSON/YAML matching the model's output specification:
NMS Modes
ClassAgnostic- Suppress overlapping boxes regardless of class (default)ClassAware- Only suppress boxes with the same class labelNone- Bypass NMS (for models with built-in NMS)
End-to-End Models (YOLO26)
YOLO26 models embed NMS directly in the model architecture (one-to-one matching heads), eliminating the need for external NMS post-processing.
Configure via the decoder_version field in the model config:
When decoder_version is "yolo26", the decoder:
- Bypasses NMS entirely (the
nmsconfig field is ignored) - Expects post-NMS output format:
[batch, N, 6+]where columns are[x1, y1, x2, y2, conf, class, ...] - Supports both detection-only and detection+segmentation variants
For non-end-to-end YOLO26 exports (end2end=false), use decoder_version: "yolov8" with explicit NMS configuration.
Non-End-to-End Mode
Models exported with end2end=false require external NMS, configurable via the nms field:
Proto Mask API
For segmentation models, the decoder provides two APIs for accessing mask prototype data:
decode_quantized_proto()— returns raw quantized proto data and mask coefficients without materializing pixel masksdecode_float_proto()— returns float proto data and mask coefficients
These are preferred when passing mask data to GPU rendering pipelines (e.g., ImageProcessor::draw_masks_proto()), as they avoid the CPU cost of materializing full-resolution masks.
// GPU rendering path: decode proto data, pass to GL for fused rendering
let = decoder.decode_quantized_proto?;
// Pass proto_data directly to GPU for fused mask overlay
processor.draw_masks_proto?;
Model Type Variants
The decoder automatically selects the appropriate model type based on the config:
| Variant | Tensors | Description |
|---|---|---|
YoloDet |
1 (detection) | Standard YOLO detection |
YoloSegDet |
2 (detection + protos) | YOLO detection + segmentation |
YoloSplitDet |
2 (boxes + scores) | Split-output detection |
YoloSplitSegDet |
4 (boxes + scores + mask_coeff + protos) | Split-output segmentation |
YoloEndToEndDet |
1 (detection) | End-to-end detection (post-NMS) |
YoloEndToEndSegDet |
2 (detection + protos) | End-to-end segmentation |
YoloSplitEndToEndDet |
3 (boxes + scores + classes) | Split end-to-end detection |
YoloSplitEndToEndSegDet |
5 (boxes + scores + classes + mask_coeff + protos) | Split end-to-end segmentation |
ModelPackDet |
2 (boxes + scores) | ModelPack detection |
ModelPackSegDet |
3 (boxes + scores + segmentation) | ModelPack segmentation |
ModelPackDetSplit |
N (detection layers) | ModelPack split detection |
ModelPackSegDetSplit |
N+1 (detection layers + segmentation) | ModelPack split segmentation |
ModelPackSeg |
1 (segmentation) | ModelPack semantic segmentation |
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.