Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle errors from Tesseract #165

Merged
merged 6 commits into from
Aug 9, 2023
Merged

fix: handle errors from Tesseract #165

merged 6 commits into from
Aug 9, 2023

Conversation

awalker4
Copy link
Contributor

@awalker4 awalker4 commented Aug 4, 2023

Certain regions of a document are failing ocr with this error:

pytesseract.pytesseract.TesseractError: (-8, 'Estimating resolution as 1250') (for some value)

When I try the same region on the CLI, I get:

$ tesseract bad_tile.jpeg output
Estimating resolution as 1813
Floating point exception

Whatever the root cause, let's catch this error and return an empty string.

Certain regions of a document are failing ocr with this error:

`pytesseract.pytesseract.TesseractError: (-8, 'Estimating resolution as 1250')`

When I try the same region on the CLI, I get:

```
$ tesseract bad_tile.jpeg output
Estimating resolution as 1813
Floating point exception
```

Whatever the root cause, let's catch this error and return an empty string.
@awalker4 awalker4 requested review from benjats07 and qued August 4, 2023 23:47
@awalker4 awalker4 requested a review from shreyanid August 5, 2023 00:03
@awalker4
Copy link
Contributor Author

awalker4 commented Aug 5, 2023

Looks like those ingest tests have been failing on main for a while, so I'm assuming we can ignore here.

@cragwolfe
Copy link
Contributor

Looks like those ingest tests have been failing on main for a while, so I'm assuming we can ignore here.

Yeah, that just indicates the current version of unstructured-inference would produce different outputs if the ingests tests are run. Hopefully, they are good different outputs!

@awalker4 awalker4 enabled auto-merge (squash) August 6, 2023 17:03
Copy link
Contributor

@shreyanid shreyanid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me! Tested in docker to reproduce the issue, and this change results in a 200 status for otherwise failing documents.

@awalker4 awalker4 merged commit 203f7ab into main Aug 9, 2023
@awalker4 awalker4 deleted the austin/tesseract-error branch August 9, 2023 23:53
cragwolfe added a commit to Unstructured-IO/unstructured that referenced this pull request Aug 10, 2023
* build(release): bump unstructured-inference

Related to downstream issue:
Unstructured-IO/unstructured-api#182

And upstream PR:
Unstructured-IO/unstructured-inference#165

---------

Co-authored-by: Shreya Nidadavolu <[email protected]>
shreyanid added a commit to Unstructured-IO/unstructured-api that referenced this pull request Aug 14, 2023
Related to downstream issue: #182
And upstream PR: Unstructured-IO/unstructured-inference#165

* remove test_parallel_mode_correct_result
* dropped the file_directory field from elements metadata

try:
return agent.detect(cropped_image)
except tesseract.TesseractError:
Copy link
Contributor

@cragwolfe cragwolfe Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a logger.warn("<something", exc_info=True)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants