POST endpoint using OCREngine 2: identical request returns either the full or a heavily truncated result (non-deterministic)

Moin,
We’re a PRO customer and are seeing non-deterministic behaviour with OCREngine=2 + isTable=true on both PRO endpoints.

Setup — all parameters sent as multipart form-data fields, file uploaded via file:
OCREngine=2
isTable=true
scale=true
detectOrientation=true
language=auto
filetype=pdf

Input: a single-page A4 German invoice scan, PDF, ~230 KB, containing a header block, an address block, a line-item table and a footer.

Symptom — the same file with the same parameters returns one of two clearly distinct results:

            response time	TextOverlay.Lines	words	ParsedText

good 1.27–1.58 s 65 259 complete
degraded 0.64–0.95 s 10 89 middle section missing
In the degraded result, ParsedText contains only lines from the very top and the very bottom of the page. The entire middle of the document — the line-item table and the totals block — is absent.

The most telling difference is in the overlay. In the good result each word has its own bounding box. In the degraded result all words of a line report one identical box:
// degraded: four words, identical Left/Top/Height/Width
{“WordText”:“WordA”,“Left”:87,“Top”:1305,“Height”:31,“Width”:311},
{“WordText”:“WordB”,“Left”:87,“Top”:1305,“Height”:31,“Width”:311},
{“WordText”:“WordC”,“Left”:87,“Top”:1305,“Height”:31,“Width”:311},
{“WordText”:“WordD”,“Left”:87,“Top”:1305,“Height”:31,“Width”:311}

Line-level geometry differs too — the first line of the page is reported as 1493/107/173/795 in one class and 1482/105/184/821 in the other. That looks like two different processing paths rather than a filtering step.
Already ruled out:

  • Parameter casing — isTable and istable both produce both outcomes.
  • Endpoint — occurs on apipro1 and apipro2; two consecutive calls to the same endpoint returned different classes.
  • Caching / repeated submissions — the degraded result also occurs on a cold first request for a document not submitted before.
  • Error signalling — OCRExitCode: 1 and IsErroredOnProcessing: false in both cases, so there is nothing to branch on.
    Response time is the only external predictor we found (4/4 in local tests; a degraded production case returned in 0.625 s).

Because both responses are reported as success, we currently cannot distinguish them without heuristics such as the duplicate-bounding-box check above. Is this a known issue in the Engine 2 table path, and is there a reliable way to detect or avoid the degraded result?

Sadly we are not able to share the document as it contains customer data. We currently try to replicate the behaviour with test documents.

Kind regards
Tim

Thanks for the report. So just to clarify: The issue happens “only” with certain documents? Any test image or PDF would be very helpful.

We run several backends, and it could be that one of them has an issue. That would explain why it happens randomly, depending where your requests gets routed.

… on both PRO endpoints.

That on the other hand is strange and hints to a different issue. The servers are not shared between the PRO endpoints :thinking:

Thanks for the fast response. As of know i can confirm that with the current test document leads to non-deterministic responses in both https://apipro1.ocr.space/parse/image and https://apipro2.ocr.space/parse/image.

I ran a controlled experiment to quantify it: 8 documents × both PRO endpoints × 25 identical repetitions each (400 requests total), classifying each response as “good” or “degraded” relative to the best result seen for that same file (degraded = word count below 50% of the file’s maximum).

Results:

  • the affected document has 10/25 degraded (40%) on apipro1 and 13/25 degraded (52%) on apipro2
  • 7 other invoices have neither degregations on both endpoints

Until now i haven’t found another affected document, there seems to be no endpoint difference and the response times seem to not predict the output.

These are PDF documents, right? Can you take a screenshot of this PDF page and then send it as PNG? Does this work better? This could point to an issue with the PDF to image conversions that we do.

That seems to be it.

Rendering the same page to a 300 dpi PNG and sending that instead of the PDF makes the problem disappear completely. As a PNG i get the full result on all 25 runs per endpoint, deterministic answers only.

I will continue searching for affected documents that i could share with you.

I’ve now found a document that i anonymised to be shareable while still being affected by the non-determinism. But sadly I’m not allowed to upload the document.

I’ve used the contact form to send you an email with the mentioned document.