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

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #392

Open
seraph900112 opened this issue Aug 16, 2024 · 1 comment

Comments

@seraph900112
Copy link

  File "/root/ZiYuShen/latex_val/.venv/lib/python3.10/site-packages/pix2tex/cli.py", line 115, in __call__
    img = minmax_size(pad(img), self.args.max_dimensions, self.args.min_dimensions)
  File "/root/ZiYuShen/latex_val/.venv/lib/python3.10/site-packages/pix2tex/cli.py", line 47, in minmax_size
    img = img.resize(size.astype(int), Image.BILINEAR)
  File "/root/ZiYuShen/latex_val/.venv/lib/python3.10/site-packages/PIL/Image.py", line 2297, in resize
    if self.size == size and box == (0, 0) + self.size:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

When calling latex_model(img), the above error will occur in some pictures.

@VModugno
Copy link

in cli.py after line 46 add these 2 lines

 size = tuple(size.astype(int)) ## added to avoid error in PIL
 img = img.resize(size, Image.BILINEAR) ### changed to avoid error in PIL

and comment out this line
#img = img.resize(size.astype(int), Image.BILINEAR)

takmin added a commit to takmin/latexocr_wrapper that referenced this issue Oct 23, 2024
takmin added a commit to takmin/latexocr_wrapper that referenced this issue 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

No branches or pull requests

2 participants