Skip to content

Hardcoded scale in TesseractOcrCliModel may not be appropropriate for every image #3866

Description

@raghuraman1

First of all Docling is great. Thanks.
Now let me describe what made me think there is a bug.

I was using a pdf acro form and populating it with data, flattening it and extracting the image.
This was my image that i was using with docling.
Its a very clean image.
I have to use images as my source.

I figured out that Docling can be configured with mulgtiple OCR engines.
I tried all of them and found that Tesseract was the better for my purpose.
Strangley docling was having some OCR issues even on my clean good quality images.
I tried using same version of tessrecat directly on the images and I did not have the OCR accuracy issues any more.

I used "tesseract -l eng .\imagename.png stdout tsv" directly after copying from my Temp folder and I got same OCR issues.
I noticed that the image had been enlarged when it was copied to the Temp folder.
I tried "tesseract -l eng .\original-image.png stdout tsv" and the errors were gone.

Bug

...
I edited this code-
https://github.com/docling-project/docling/blob/9b51f4f857176cdd95cef53e2ec7f5f32ffbc6a5/docling/models/stages/ocr/tesseract_ocr_cli_model.py

I changed the line "self.scale = 3" to "self.scale = 1" and the OCR issues were gone.
The layout logic did shift a bit but was manageable.

I dont suppose we should be hardcoding the scale factor to 3.
Maybe it should be configurable.
Even better would be to have a logic that checks the image and figures out the effective resolution, image quality and figures out the scale more dynamically

Steps to reproduce

...

Docling version

docling-serve --version
Docling Serve version: 1.26.0
Docling Jobkit version: 2.1.0
Docling version: 2.113.0
Docling Core version: 2.87.1
Docling IBM Models version: 3.13.3
Docling Parse version: 7.8.0
Python: cpython-311 (3.11.9)
Platform: Windows-10-10.0.26200-SP0

docling --version
Docling version: 2.113.0
Docling Core version: 2.87.1
Docling IBM Models version: 3.13.3
Docling Parse version: 7.8.0
Python: cpython-311 (3.11.9)
Platform: Windows-10-10.0.26200-SP0
...

Python version

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions