← All blogs

Computer vision

Test-time augmentation vs retraining: a flip beat 658 weight edits

In a research experiment, we tried two cheap ways to make a trained breed classifier more accurate without another training run. One was to score each crop twice, once mirrored, and average the two. The other was to edit the model's weights directly, 658 times in all. The flip added 1.33 points of dog top-1 on 6,070 held-out dogs. None of the edits held up, and the reason is worth knowing before you spend a week on either.

Rubix Labs4 min read
Left: averaging each crop with its mirror image moved dog top-1 from 4,758 to 4,839 of 6,070 held-out dogs, plus 1.33 points, and added 6 of 482 cats. Right: 658 edits to the trained model, 52 from weights or class counts and 606 to the final layer computed from data; the one nominee changed dog top-1 from 2,361 to 2,362 of 3,029 on the held-back half, with 13 gains and 12 losses.
Results from our research experiment on held-out test photos the model never saw in training, scored on ground-truth boxes. Not a measure of real-world accuracy.

The flip: score twice, average

For each crop, we ran the classifier on the original and on its horizontal mirror and averaged the scores. On 6,070 held-out dogs scored on ground-truth boxes, top-1 rose from 4,758 to 4,839, which is 1.33 points. Top-3 gained 56 and top-5 gained 26. Cats moved less: 6, 3 and 1 more correct out of 482.

It costs something. The classifier runs twice per image, so hosted compute per image goes up, and the whole workflow would need its parity checks repeated before we'd trust the new numbers. The appeal is that you can measure it and roll it back without touching the weights.

A breed doesn't change when you mirror a photo, so averaging two views can smooth out quirks of a single one. That's the usual intuition; our test didn't isolate why it helped.

658 edits to the trained model

Earlier rounds had tried 52 edits across the two vision models, computed from the weights alone or from class counts: row normalisation, bias and prior corrections and spectral changes. None survived.

This round computed the edits from data, still with no gradient descent and no change outside the final 1280-to-353 projection. We extracted features for 62,413 training rows, the 6,552 held-out animals and 1,084 labelled development animals, then split the held-out animals in half. One half, SELECT, chose candidates. The other, CONFIRM, stayed closed until a single nominee existed. The rule, fixed in advance, was that no cat or dog count could fall on SELECT or on the development set.

The first 70 candidates included folding the flip into the layer by least squares and blending in class-mean (LDA) directions. Another 536 blended only the dog rows. That's 606 in this round. The LDA blend raised dog top-1 by 13 to 15 on SELECT, out of 3,041, but cost cats and cat species decisions, so nothing passed the original rule.

Under a looser rule we wrote down before opening CONFIRM, one nominee went through. On CONFIRM, dog top-1 went from 2,361 to 2,362 of 3,029: thirteen photos gained and twelve lost, an exact paired p of 1.0. It also lost one species suggestion, so it failed the looser rule as well.

Why editing the last layer couldn't work

The final layer already fitted what it was given. It scored 93.4% top-1 on its own training rows and 78% on held-out photos, and that gap lives in the features coming out of the backbone, which no edit to the last layer can reach. Folding the flip into the layer did nothing either. As we read it, the flip's benefit comes from running the backbone on a second view, which a fixed linear change can't reproduce.

We've now used the CONFIRM half once, so it won't select anything again. If you run this kind of search, decide where the held-back data will be spent before you start, because it's easy to fish in a test set without noticing.

When retraining is the answer

Test-time augmentation is a good first move when the backbone is decent and you can afford the extra compute. It won't add a class the model doesn't have, and it won't fix features that can't separate two breeds. Our larger teacher scored 63% cat and 80% dog top-1 on our development panel, against 53% and 72% for this smaller student. Closing that gap means training: more distillation data or a larger student.

Some of the biggest wins weren't in the model at all. Adding mixed and non-pedigree choices, and asking 'cat or dog?' when two models disagree, fixes what a person sees without touching a weight.

When retraining is the answer
ChangeMeasured effectCost
Horizontal flip averaging at inferenceDogs +1.33 points top-1 (4,758 to 4,839 of 6,070); cats +6 of 482Classifier runs twice per image; requalify the workflow
52 edits from weights or class countsNone survivedAnalysis time
606 data-computed edits to the final layerOne nominee: +1 dog on CONFIRM, 13 gained and 12 lostUsed up the CONFIRM half
Larger student or more distillation dataNot measured in this roundA new training run

Bring us the model you can't retrain yet

If you have a vision model that's nearly good enough and no appetite for another training run, we'd start where this experiment did: hold data back properly, try inference-time changes such as flips, and measure them on photos the model never saw. Rubix can help set up that evaluation and tell you when it is time for a new training run. Custom vision work is listed on our pricing page.