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 "ValueError: height and width must be > 0" in minmax_size method #30

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

ali6parmak
Copy link
Contributor

Bug Report and Fix

Description of the Bug

I have a pipeline to find where the formulas are located in a page, and pass their coordinates to rapid-latex-ocr to extract them in LaTeX format. And this process is failed in the following specific image that is found by my pipeline (even though there is no formula in it, it should not fail the process):

formula_image_6_394

Error Message

ValueError: height and width must be > 0

Steps to Reproduce

  1. Install rapid-latex-ocr
  2. Download the image and try to process it with rapid-latex-ocr
  • The error occurs in the minmax_size function in utils.py

Proposed Fix

In the file rapid_latex_ocr/utils.py, in the minmax_size function, after this line:

size = np.array(img.size) // max(ratios)

add this line to ensure the size is at least 1:

size = np.maximum(size, 1)

Additional Notes

This fix has been tested on Python 3.11 and resolves this error.

@SWHL SWHL self-requested a review October 24, 2024 01:35
Copy link
Member

@SWHL SWHL left a comment

Choose a reason for hiding this comment

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

LGTM

@SWHL SWHL merged commit b5258f8 into RapidAI:main Oct 24, 2024
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.

2 participants