The mAP in your training log is an FP32 number; the board runs a different one
A detector that reports a high mean average precision in a training notebook and miscounts boxes on a factory floor is not a contradiction. It is two different measurements of two different graphs. One is a floating-point network running on a workstation. The other is a quantised network running on an NPU, with per-tensor scale factors that were fixed in advance from a sample of images.
The distance between those two numbers is not a bug in the training. It is the cost of the conversion, and both of the major edge toolchains document exactly where it comes from.
Three conversions, one of them quiet
Getting a detector from a training framework onto a Chinese edge SoC involves three separate transformations, and they fail in very different ways.
The first is the graph export: a framework checkpoint becomes an ONNX graph. Failures here are loud. An operator with no equivalent, an opset the converter cannot read, a dynamic shape it will not accept, and the conversion stops with a message.
The second is the platform conversion: ONNX becomes the runtime's own artefact. Rockchip's RKNN-Toolkit2 produces an rknn file for RK3588 and its siblings; TensorRT produces an engine for Jetson. These failures are mostly loud as well, with one important silent class covered below.
The third is precision. A float graph becomes an INT8 graph, and this step is quiet. The conversion reports success, the artefact loads, the model runs, and the detections are slightly different from the ones that were validated on the workstation.
That third step is where a project's promised accuracy actually gets decided, and it is the step with the least visibility in a training log.
What INT8 costs, in the vendor's own terms
TensorRT's developer guide names the two error sources directly, and the naming is worth borrowing because it makes the trade-off concrete.
Discretisation error increases as each quantised value has to represent a wider range, so resolution gets coarser. Truncation error is the opposite failure: values that fall outside the representable range are clamped, and the information in them is lost.
Choosing a scale factor for a tensor means choosing a position between those two. Move the range wider to capture outliers and every step gets coarser. Move it narrower and the outliers get clipped. TensorRT states plainly that deciding the best scale is not an exact science, and ships several calibrators, entropy, min-max and a legacy variant, because there is no single correct answer for every network.
The guide also gives one useful anchor for how much data the choice needs: about five hundred images are sufficient for calibrating ImageNet classification networks. A fixed camera watching one doorway is a far narrower distribution than ImageNet, so a detection model can usually be calibrated with fewer images than that. Fewer is not the same as any.
The mechanism behind the parameter
Rockchip's RKNN user guide exposes the whole calibration step as a single build parameter. Quantisation is optional when the model is built, and when it is enabled the toolkit needs a dataset to calibrate against:
rknn.build(do_quantization=True, dataset='./dataset.txt')
The dataset is a text file listing image paths, one per line. With quantisation on, the toolkit runs those images through the float graph, records the activation distribution of each tensor, and fixes the scale and zero point accordingly. The guide recommends enabling quantisation rather than leaving it off.
Two details in that description matter more than the call itself. The conversion runs on a PC, not on the board, so the artefact that ships carries a set of scale factors that were decided before deployment and cannot be adjusted afterwards. And the calibration images are described by the guide only as a dataset. Nothing in the format enforces that they resemble the deployment site. That judgement is entirely the integrator's.
| Target | Converter | Artefact | Calibration input |
|---|---|---|---|
| Rockchip RK3588 and related SoCs | RKNN-Toolkit2 | rknn model | text file of image paths |
| NVIDIA Jetson | TensorRT | engine | calibrator implementation plus sample batches, or an explicit quantisation graph |
| x86 host, for reference | none, the ONNX graph runs directly | onnx model | not applicable at FP32 |
The third row is worth keeping in a project folder, because it is the only build in the set with no quantisation step. It is what the training log measured. It is also the reason a working demo on a laptop proves nothing about the box.
The calibration set is a design decision
The common failure is not choosing a bad algorithm. It is choosing convenient images.
A calibration set gathered at midday, in good weather, under even light produces scale factors tuned to that histogram. The deployment runs twenty-four hours a day, and the frames that matter at night have a very different distribution. The effect is not a uniform loss of accuracy. It concentrates wherever the activation range was undersampled during calibration, and for a detection model that region tends to be small, low-contrast and distant objects, which is usually the reason the system was bought.
That last consequence follows from the two error terms rather than from a vendor measurement, so treat it as reasoning rather than a reported figure. The remedy it points at is still the right one: calibrate on frames drawn from the actual site, including the bad conditions, and keep the calibration set separate from the validation set so that the validation result means something.
Two failures that sit next to the accuracy problem
The first is a silent latency failure. An operator that the target runtime cannot accelerate does not stop the model. Provided the converter accepts the graph, that layer runs on the CPU instead of the NPU. Accuracy is unchanged and nothing in the output mentions it, but the per-frame budget is now wrong, and on a box driving several streams the error compounds because the budget was measured on one.
The loud version of that problem is a conversion that refuses to build, which is easy to handle. The quiet version is a build that succeeds and then misses its frame rate on site.
The second is a preprocessing mismatch that produces a total failure instead of a degraded one. Rockchip's converter lets normalisation be baked into the model through mean and std configuration, so the application can pass raw pixel bytes straight from the decoder. If the application then divides by 255 as well, the network receives a distribution it never saw. The output is not slightly worse. It is wrong, and it looks like a broken model rather than a duplicated scaling step.
What to measure before quoting a number
The accuracy that counts is the one measured on the target board, through the runtime that will run in production, on a validation set that was not used for calibration. Four things belong in that measurement:
| Item | Why it matters |
|---|---|
| Per-class scores, not one aggregate | one class usually absorbs most of the quantisation loss |
| FP32 and INT8 side by side, with artefact sizes | shows what the compression bought and what it cost |
| Latency at the deployed resolution and stream count | includes capture, preprocessing and post-processing, not the network alone |
| The calibration set, stored beside the artefact | without it the number cannot be reproduced or defended |
One rule earns its own line: do not lower the confidence threshold to recover the detections INT8 lost. That converts an accuracy problem into a false-alarm problem, hides the cause, and pushes the work onto whoever operates the site.
What this does not settle
No vendor publishes a cross-platform accuracy loss figure, and none could. The loss depends on the calibration set the integrator assembles, so it is a property of a build, not of a chip.
Whether to quantise at all is also a per-project decision. On a single-stream box running a small model, FP16 costs little throughput and removes the calibration problem from the project entirely. On a box driving many streams, INT8 is where the throughput is, and the calibration set becomes a deliverable in its own right.
The output of a deployment is not a converted file. It is a number measured on the hardware that will run it, together with the images that produced it, so that the next engineer can repeat the measurement rather than trust it.