A general-purpose optimisation platform for vision models: lighter, without retraining
Most vision models that reach a device were trained on a server and never slimmed down. They work, they are just heavier than they need to be. We built a platform that makes them lighter without touching the training, and this post covers what it needs from you, what it does and what comes back.
The data: only a validation subset
We never ask for your training set. It is the large, costly and often confidential part of a vision project, and nothing here retrains, so it stays with you. We need the trained model and a validation set, the few hundred labelled images you already keep to check it. Unlabelled images are welcome too, and need no labelling work, as long as they look like what the model will see in deployment.
The labelled set is split once. About 15 % of it, 80 of 500 images in most of our tests, ranks candidates during the search. The other 85 % is held out. The search never sees these images, but they pick the winner among the finalists, so its score can lean slightly optimistic; a third, untouched set would remove that. Every number in the report, the original model’s included, comes from them. The unlabelled images measure the value ranges INT8 needs.
The held-out images also set the precision. With 420 of them, small changes in accuracy are hard to tell from sampling noise, so the report gives a 95 % interval for every change, and a larger validation set narrows it.
| What you give us | Needed? | What it unlocks |
|---|---|---|
| The trained model | required | FP16 and uncalibrated INT8: smaller, but the accuracy cannot be checked |
| A labelled validation set, a few hundred images | required to check accuracy | every technique in this post, each version checked on your data |
| Unlabelled images from your domain | optional | better calibration, and more labelled images kept for the final check |
| A training set | optional, not used today | fine-tuning and quantisation-aware training, later |
Before changing anything, the platform measures your original model on your data, class by class, and catches upload mistakes such as a wrong class order or a forgotten normalisation, which quietly cost one of our test classifiers 2 percentage points of accuracy, 97.1 % down to 95.1 %.
The goal is a hard rule: a version that breaks it is never recommended, however small. This is why every model in this post keeps its accuracy. The platform offers a few goals, from “keep today’s quality, make it lighter” to “no measurable change”. All our tests used the first, and a version must meet every part of it:
- the model’s accuracy drops by at most 1 percentage point: an original at 90 % must stay at 89 % or above. For segmentation and detection the same rule applies to their standard scores, mIoU and mAP;
- no single class loses more than 2 correctly classified images in classification, counted on the smallest class, 3 percentage points of IoU in segmentation or 5 percentage points of AP in detection;
- on COCO, the mAP on small objects drops by at most 2 percentage points.
Test set: 33 models across three tasks
One model cannot tell a flaw in the method from a quirk of its architecture, so we test 33 public, edge-sized model–dataset pairs across three tasks:
- Classification, 17 pairs: dog breeds (Imagewoof), satellite images (EuroSAT), histology (PathMNIST).
- Segmentation, 6 pairs: pets (Oxford Pets), everyday scenes (Pascal VOC), eyes.
- Object detection, 10 pairs: COCO and Pascal VOC.
The procedure: four steps and a feedback loop
Every pair goes through the same web service a client uses, unattended, in four steps, and a fifth closes the loop:
- Check-up: the original model is measured on your held-out images, class by class, and the goal is set.
- Search: versions are built and scored on the search images, first from fixed rules, then by a Bayesian search.
- Refine: the best versions and the closest misses get their neighbours tried.
- Final check: about eight finalists are scored on the held-out images, and the smallest that meets the goal wins.
- Feedback: every run doubles as a field test of the optimiser. Whatever broke or underperformed is written down as a lesson and fixed, and the fix is checked on the next run: 51 lessons from 14 field tests so far.
All 33 pairs took 16.5 hours on one server. Detectors are cut before non-maximum suppression, the step that removes duplicate boxes, and the platform applies the same one to every version, as a deployment on an accelerator does.
Optimisation techniques: four, all post-training
Everything is post-training: the weights are changed directly, never retrained, and labels only check quality. Four techniques do the work, from the largest change to the finest; quantisation comes in two forms, FP16 and INT8.
The INT8 scan decides which layers stay in float, hence versions such as “INT8, 1 layer in float”; our quantization post shows what the rounding costs. The output is always standard ONNX, cleaned up by the runtime as in compilation, so vendor toolchains start from a standard format, within their operator support.
How the search chooses
The search works inside the goal set at the check-up: it looks for the smallest version, and discards any version that breaks the goal.
Trying every combination is out of reach. Five input sizes, no pruning or eight levels of it, FP32, FP16 or INT8, and for INT8 three calibrations and up to 15 layers kept in float: 2,250 versions for the U-Net alone, about 17 hours at the half-minute each takes to build and score. The search built 44 of them, in 20 minutes and three steps. No language model is involved: every choice follows from measurements, and with the same inputs, settings and software versions, the search gives the same result.
- First tries, from fixed rules. Before the search, a scan measures layer by layer, without labels, how much INT8 and pruning hurt. Fixed rules turn that into the first versions: FP16, plain INT8 with each calibration, INT8 with the most fragile layers kept in float, and a middle pruning level.
- Bayesian search, guided by the scores so far. Optuna’s TPE (Tree-structured Parzen Estimator) proposes each next version from how the previous ones scored, steering towards small and accurate. It stops after 40 proposals, or after 12 in a row that find nothing better. A version already built is never built again.
- Refine, small changes around the best results. The three best versions and the two closest misses get small tweaks: one layer more or fewer in float, another calibration, a nearby input size. Eleven of the 33 winners came from this step.
Each pair builds at most 54 versions, 40 in the first two steps and 14 in refine; in our run, 27 per model on average. Nothing is retrained: a version is converted, then scored. A quick check without labels drops any version that changes too many of the original’s predictions, and the rest are scored against the goal on the search images. Up to eight finalists, 6 on average, are then compared with the original on the held-out images, and the smallest that meets the goal wins.
On the U-Net (panel A), the first tries reached 4.2 MB and the Bayesian search 3.1 MB, with a smaller input. On ResNet18 (panel B), pruning and a smaller input broke the model; the winner came from refine, INT8 with one layer in float, 3.9× smaller.
The final check protects the result. With 80 search images, one image is 1.25 percentage points of accuracy, so a version can look better on the search images than it is. Re-checking the finalists on the held-out images changed our pick in 17 of the 33 cases.
Results
All 33 tested models came back smaller, and every score stayed within the goal. Each arrow joins an original model to the version we recommend, both measured on the same held-out images: its length is the size saved, its drop the score lost.
The classification intervals are the widest because each image counts once: with about 420 held-out images, ±1.5 to 2 percentage points of accuracy is as precise as it gets, and a larger validation set narrows it.
Quantisation does most of the work. INT8 won 19 of the 33 cases, at 2.6× to 3.9× smaller, and more where pruning or a smaller input joined it. FP16 won the other 14, at about 2×, where INT8 missed the goal.
Some models refuse INT8, and the report says why. The transformer detectors, D-FINE-N and RT-DETR, miss the goal in INT8 by 1.5 to 3.6 percentage points of mAP: attention and the decoder’s box refinement amplify the rounding error. On VOC, one class of the LRASPP segmenter loses 6 percentage points of IoU in INT8 whatever stays in float. FP16 won in both cases, and 16-bit layers on the board are the next lever.
Without retraining, pruning rarely reaches far. Residual connections tie most modern networks together: on RegNetY it could remove 0.1 % of the compute, and on the transformer detectors and EfficientDet nothing, so it was left out, with the reason. Where it reaches, it pays: 33 % less compute on the U-Net, 58 % on the eye segmenter. Low-rank factorisation, by contrast, never gave more than a polish, 1 % on RT-DETR.
What Kernwerk delivers
For every model you send, we deliver three things, all built from the same measurements:
- The optimised models, in standard ONNX: the one we recommend and its alternatives, each traced back to its original, its recipe and its file.
- The Kernwerk report, 4 to 5 pages, for your decision: what we changed, quality per class before and after, every version we tried in one chart, and why we left any technique out.
- The technical report, for your engineers: every trial, our search’s estimates against the held-out verdict, and a confidence interval on every change.
We check every PDF automatically for text drawn over other text before it leaves us. Yes, we test our own reports.
Next: one board
This generalist mode ranks versions by size and compute, and promises nothing about speed on a given chip. On a real NPU (neural processing unit), the vendor’s toolchain redoes part of the work: it requantises from the float model, sends layers it cannot run back to the CPU, and may want float layers in 16-bit. Our lab showed how much those details move a model.
Next, we run all 33 models on one target board and measure what survives, what falls back and how fast each version really is. The findings become rules the optimiser follows for that board.
Send us a trained model and a few hundred of your validation images. We will tell you how much lighter it gets, what it costs per class, and what we left out and why. Talk to us.