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

page.synthesize() returns error when assume_straight_pages=False #1692

Closed
hienphan161 opened this issue Aug 13, 2024 · 2 comments
Closed

page.synthesize() returns error when assume_straight_pages=False #1692

hienphan161 opened this issue Aug 13, 2024 · 2 comments
Labels
good first issue Good for newcomers module: utils Related to doctr.utils type: bug Something isn't working
Milestone

Comments

@hienphan161
Copy link

Bug description

I've seen that when I use assume_straight_pages=False, it makes result.pages[0].synthesize() stop working.

Code snippet to reproduce the bug

predictor = ocr_predictor(
  pretrained=True,
  assume_straight_pages=False,
  straighten_pages=True,
  detect_orientation=True,
  resolve_blocks=True
)

file_name = "/content/vecteezy_modern-professional-business-card-creative-and-simple_9010481 - Copy.jpg"
image = Image.open(file_name)
image = ImageOps.exif_transpose(image)

result = predictor([np.asarray(image)])
result.pages[0].synthesize()

Error traceback

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-7-7d5fc2bce17c>](https://localhost:8080/#) in <cell line: 1>()
----> 1 result.pages[0].synthesize()

1 frames
[/usr/local/lib/python3.10/dist-packages/doctr/io/elements.py](https://localhost:8080/#) in synthesize(self, **kwargs)
    315             synthesized page
    316         """
--> 317         return synthesize_page(self.export(), **kwargs)
    318 
    319     def export_as_xml(self, file_title: str = "docTR - XML export (hOCR)") -> Tuple[bytes, ET.ElementTree]:

[/usr/local/lib/python3.10/dist-packages/doctr/utils/reconstitution.py](https://localhost:8080/#) in synthesize_page(page, draw_proba, font_family)
     41             for word in line["words"]:
     42                 # Get absolute word geometry
---> 43                 (xmin, ymin), (xmax, ymax) = word["geometry"]
     44                 xmin, xmax = int(round(w * xmin)), int(round(w * xmax))
     45                 ymin, ymax = int(round(h * ymin)), int(round(h * ymax))

ValueError: too many values to unpack (expected 2)

Environment

DocTR version: v0.9.0
TensorFlow version: 2.17.0
PyTorch version: 2.3.1+cu121 (torchvision 0.18.1+cu121)
OpenCV version: 4.10.0
OS: Ubuntu 22.04.3 LTS
Python version: 3.10.12
Is CUDA available (TensorFlow): Yes
Is CUDA available (PyTorch): Yes
CUDA runtime version: 12.2.140
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 535.104.05
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.6
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.6

Deep Learning backend

is_tf_available: False
is_torch_available: True

@hienphan161 hienphan161 added the type: bug Something isn't working label Aug 13, 2024
@felixdittrich92
Copy link
Contributor

Hi @hienphan161 👋,

Thanks for reporting.

You are right.
We don't have logic to reconstitute polygons (possible rotated texts) in synthesize() yet.
So there is a missing check for the geometry or exception handling. 👍

@felixdittrich92 felixdittrich92 added this to the 0.9.1 milestone Aug 13, 2024
@felixdittrich92 felixdittrich92 added good first issue Good for newcomers module: utils Related to doctr.utils labels Aug 13, 2024
@felixdittrich92 felixdittrich92 modified the milestones: 0.9.1, 0.10.0 Oct 10, 2024
@felixdittrich92
Copy link
Contributor

#1750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers module: utils Related to doctr.utils type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants