DEV Community

yue xing
yue xing

Posted on

I upscaled with a ground truth, and the batch code came back wrong

Most upscaling comparisons you see online are useless, and it took me a broken batch code to figure out why. They put the blurry input on the left and the AI result on the right, and then your eyes decide. But your eyes have nothing to compare against — there is no correct answer in the frame. Sharper always wins that contest, whether or not it is true.

So I built the test the other way around for a course project. I started from four sharp images I already had, treated each one as the ground truth (the known-correct version of that picture), downscaled every one of them to a quarter of its size, fed only the small versions to the upscaler, and asked for 4x back. Now every output has an exact reference, and I can compare them pixel by pixel instead of squinting. Two samples I generated myself with a script — a fake product photo and a fake invoice screenshot with a table, brand names and order numbers all invented — plus a line-art icon, plus one street photo taken from Wikimedia Commons under CC0. That last one is not mine, it is third-party material used for the test.

The tool was the AI upscaler on ImgIng (https://imging.ai/), mostly for boring reasons: no signup, no cost, and it runs locally in the browser, which I verified by watching the Network panel the whole time — zero bytes of image data went out. It ships five model tiers, and I ran every sample through all five, which is why I can say "all five tiers" below and mean it. One detail worth copying if you repeat this: the export defaults to WebP, and I switched it to PNG for every run. Lossy encoding on top of the result would have leaked into the numbers.

The clearest failure was a batch code printed on the product packaging. The ground truth reads A7K-2291. After downscaling, that line is about five pixels tall — five rows of pixels for the whole line, so the strokes have already merged into each other. Plain interpolation (the dumb old method: average the neighbouring pixels and stretch) gave me a smeared mess that I could still read correctly as A7K-2291. All five AI tiers turned it into A7K(2201: the tail of the 9 is gone so it reads as 0, and the hyphen became an opening bracket. The characters are crisp. The value is wrong.

The same batch code: interpolation is blurry but right, AI is sharp but wrong

That is the part that bothers me. A blurry image tells you it is blurry, so you go find the original. A sharp wrong one does not tell you anything.

Once I lined the samples up by font size, the boundary stopped being about text at all. A 20px Chinese line, five pixels tall after downscaling: all five tiers scored 0 out of 9 characters. The same sentence set at 28px, seven pixels tall: interpolation kept 9 out of 9 readable, AI kept 3. One step up, a spec line at 34px leaving about 8.5 pixels: the digits in 200 mL came back correct while the characters next to them were swapped for different ones. The same thing shows up in the street photo — the large lettering on an aircraft fuselage came back sharper and closer to the truth, while a much smaller URL on the same image was wiped out entirely and distant road-sign numbers were redrawn as decorative diagonal hatching. The dividing line is not "is it text", it is "how many pixels survived the downscale". Information that is gone is gone, and a bigger model does not bring it back.

I also measured why the output looks so convincing. In the text regions, stroke area came back 26% to 41% higher than the ground truth and edge sharpness matched or exceeded it — while the actual distance from the truth was 2.25 to 3.37 dB worse than plain interpolation. And on a document sample that is pure greyscale, the truth and the interpolated result both contain 0.000% coloured pixels, while the five AI tiers produced between 0.305% and 2.595%. Colour cannot be recovered from an image that never had any.

None of this makes AI upscaling useless. On the line-art icon it won outright, 27.58 dB against 22.87 for interpolation, and it was slightly ahead on the photo too. It lost only on the two samples containing small text: 26.48 against 27.85 on the product shot, 22.88 against 23.62 on the document.

How close each upscaled result lands to the ground truth

What I do now is simple enough. Upscaled output is fine to look at, but anything I have to read a value out of — order numbers, batch codes, quantities, prices, small body text — goes back to the original file before it lands in a report. Old photographs, portraits and ID documents are the case everyone asks about, and I have nothing to say about them: there was not a single real face or document in my samples, deliberately, so I am not extending any of this to them.

The method transfers to whatever tool you use. Take an image you know is sharp, shrink it 4x, upscale it back, and put the two side by side at 300%. It is a twenty-minute experiment and it permanently changed how much I trust a crisp-looking result.

Top comments (0)