docling-project / docling-project/docling

Typo in the smoldocling demo sources?

Open
#1,621 1 comment 0 reactions 1 assignee Claimed by @nassarofficial View on GitHub
bug smoldocling triage/close-stale
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
3d 4h
Merged PRs (30d)
98

Description

Hello,

Looking at [Smoldocling demo sources](https://huggingface.co/spaces/ds4sd/SmolDocling-256M-Demo/blob/12df581e7fb68a527eb8e857c6a1caea6da3828c/app.py#L35) - should coordinates passed to OCR prompt be in the 500x500 range or it should be pixel numbers?

In `normalize_values` function OCR region coordinates get normalized with the maximum region coordinate, not with the actual image size which looks rather strange, additionally:
``` python
examples=[[{"text": "Convert this page to docling.", "files": ["example_images/2d0fbcc50e88065a040a537b717620e964fb4453314b71d83f3ed3425addcef6.png"]}],
[{"text": "Convert this table to OTSL.", "files": ["example_images/image-2.jpg"]}],
[{"text": "Convert code to text.", "files": ["example_images/7666.jpg"]}],
[{"text": "Convert formula to latex.", "files": ["example_images/2433.jpg"]}],
[{"text": "Convert chart to OTSL.", "files": ["example_images/06236926002285.png"]}],
[{"text": "OCR the text in location [47, 531, 167, 565]", "files": ["example_images/s2w_example.png"]}],
[{"text": "Extract all section header elements on the page.", "files": ["example_images/paper_3.png"]}],
[{"text": "Identify element at location [123, 413, 1059, 1061]", "files": ["example_images/redhat.png"]}],
[{"text": "Convert this page to docling.", "files": ["example_images/gazette_de_france.jpg"]}],
]
```
Is it a typo in the demo source? Seems like normalization does not work at all for the `OCR the text in location [47, 531, 167, 565]` prompt because `normalize_values` is called only if prompt contains `OCR at text at` substring:
``` python
if "OCR at text at" in text or "Identify element" in text or "formula" in text:
text = normalize_values(text, target_max=500)
```
Indeed, if I pass `OCR the text in location [47, 531, 167, 565]` with `example_images/s2w_example.png` without normalization and assuming I'm dealing with pixel coordinates, I get expected result . However, it does not work for other regions for me.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.