DEV Community

Tomer Bar-Meir (Tom)
Tomer Bar-Meir (Tom)

Posted on

We Built an OCR Fix for Our Rotation Detector. It Made Things Worse.

The bug

BlueVetaUpright is an API that looks at a product photo and tells you whether it's sideways or upside down, and by exactly how much. It's built on a combined model (a classifier plus a separate fine-angle detector, arbitrated together), benchmarked at 99%+ accuracy on clean rotations.

A customer's pack included two photos that got rotated the wrong way. On inspection, both turned out to be WhatsApp conversation screenshots, not product photos at all, but they'd been fed into the pipeline anyway. The model read them with full confidence and got the rotation completely backwards.

The root cause wasn't subtle once we looked: our ground-truth training pool is about 89% stock product photography. It has essentially zero examples of screenshots or app UI chrome. Not an inherent visual-confusion ceiling, a real, specific gap in what the model had ever seen.

Idea #1: read the text

Screenshots are full of real, legible text. Product photos usually aren't (or if they are, it's a short label). So the idea was: run OCR at all 4 candidate rotations, and if one orientation reads dramatically more legible text than the others, that's a strong, independent signal about which way is actually up.

We built this as a flag-only check first: never override the model's own answer, just mark the response resolved: false on disagreement so a human could look. That got rejected internally, and fairly so: a flag nobody acts on isn't a fix, it's a note to self.

Idea #2: let it actually override

So we built it properly: wired directly into the arbitration step, with one condition: it only votes on a strong, one-sided signal (a minimum character count, and a minimum margin over the next-best rotation). And one hard rule before it could ship: test it against the WHOLE system, not just the 2 bugs that prompted it, and report the result honestly either way.

Here's the honest result:

  • On a held-out set of 3,576 cases the model had never trained on, overall accuracy went from 86.49% to 85.88%, and accuracy on clean rotations (the easy case, no tilt) dropped from 99.16% to 96.14%. The check fired 49 overrides; 13 were correct, 36 were wrong. A 73.5% false-override rate.
  • On our main, harder internal test pool, it was worse. The clean-rotation, text-bearing subset dropped from 99.31% to 86.34%. On the full clean-rotation test specifically, every single override it fired was wrong: 0 correct out of 56.

We tried four different ways to calibrate it tighter: stricter text-match thresholds at three different strengths, a "reject if it's also readable upside-down" check, and a self-agreement re-read. None of them worked. Every variant either still regressed the system, or stopped catching the two original screenshot bugs it was built for.

Why it's structural, not a tuning problem

A raw "how much text did I read, and how much more than the next-best rotation" signal can't actually tell a screenshot apart from a pile of scattered small products, a bilingual product label, or a circular dial face, all of which are comparably legible at more than one rotation. Roughly 6% of our real test pool falls into one of those categories. OCR confidence alone doesn't know the difference between "this is a screenshot" and "this is a watch face."

What we actually shipped: nothing

Both the flag and the override are dead code now. The two original screenshot bugs are still a known, open gap, tracked, not fixed, not hidden. We'd rather ship a system that's honest about a known blind spot than one with a "fix" that quietly makes 56 other photos worse to catch 2.

If anyone's solved orientation detection on documents or screenshots mixed into a product-photo pipeline, genuinely curious how you approached it. We've separately benchmarked BlueVetaUpright against ChatGPT's own vision model on pure product photos (+15.2 points, 91.1% vs 75.9%, 95% CI [+10.4pp, +20.0pp]), but this specific failure mode is still open.


BlueVetaUpright is a pay-per-call API for detecting and fixing product photo rotation. Full docs: https://blueveta.com/upright

Top comments (3)

Collapse
 
userxnom profile image
Abdullah Naseer •

The part of this I respect most is that you shipped nothing. Most teams would have kept the flag version and called it a safeguard, even though you already knew a flag nobody acts on is just a slower way of shipping the same bug. Killing both versions after the held-out numbers moved the wrong way — 86.49% to 85.32%, and clean rotations dropping from 99.16% to 96.14% — is the harder call, and the honest one.

The structural point is the one I would have missed: a raw 'how much text did I read' signal cannot tell a screenshot's real text from a label's short text, so it punishes exactly the clean product photos your model is best at. Your 89%-stock-photography training pool explains the original bug better than any tuning ever could.

Since the two screenshot bugs are still open, which direction looks more promising now — teaching the pipeline to spot screenshots before they reach the model, or adding screenshot examples to the training pool so the model stops reading them with full confidence?

Collapse
 
tomerbarm profile image
Tomer Bar-Meir (Tom) •

Good question — and small note, that number's actually 85.88%, not 85.32%, for the record.

We've been looking at both directions and have gotten mixed results so far — nothing clean-cut enough yet to say one approach has won. We'll share more once there's something solid to report.

Collapse
 
aifliproom profile image
AI Flip Room •

Shipping nothing was the right call. I'd gate before the model instead of adding a vote after it: an exact phone-screen aspect ratio plus large flat blocks of UI colour is a cheap "probably a screenshot" check, and it only touches those files, so your clean-rotation numbers stay put. Do you know how many real product photos in your pool would trip a rule like that?