lukas-blecher / LaTeX-OCR

pix2tex: Using a ViT to convert images of equations into LaTeX code.
https://lukas-blecher.github.io/LaTeX-OCR/
MIT License
12.06k stars 993 forks source link

Model generates wrong LaTeX codes (five fonts, 3 versions of LaTeXOCR) #161

Open mailanmi opened 2 years ago

mailanmi commented 2 years ago

I tried to generate LateX codes for a few equations in all five fonts mentioned in the README (Latin Modern Math, GFSNeohellenicMath.otf, Asana Math, XITS Math, Cambria Math) using 3 versions of the program (GUI, Colab version, pix2tex command line tool) However, in some cases I got incorrect outputs.

Here are a few examples:

1 a. Input file: Wzor_20

b. Output generated by pix2tex tool

2. a. Input file Wzor_2

b. Output generated by pix2tex tool

-Latex code: \sqrt{\left(\operatorname*{lim}{x\rightarrow0}\frac{-\ln(1+25(e^{-x}-1))}{x}\right)^{2}}-\left(\sum{k=0}^{\infty}\Bigg(\frac{23}{24}\Bigg)^{k}

3. a. Input file Wzor_20

b. Output generated by GUI version

image-20220609-132044

lukas-blecher commented 2 years ago

Sometimes the model is not sure about the output and the second time you input the same image the result might be different. When I tried out your example images with the cli I got

  1. \prod_{i=1}^{n}n! (correct)
    • \sqrt{\left(\operatorname*{lim}_{x\to0}\frac{-\ln(1+25(e^{-x}-1))}{x}\right)^{2}}-\left(\sum_{k=0}^{\infty}\frac{\left(23\right)^{k}}{(24)}\right)^{2} (incorrect)
    • {\sqrt{\left(\operatorname*{lim}_{x\to0}{\frac{\ln(1+25(e^{-x}-1))}{x}}\right)^{2}-\left(\sum_{k=0}^{\infty}\left({\frac{23}{24}}\right)^{k}\right)^{2}}} (correct) second time around
  2. \prod_{i=1}^{n}n! (correct)

So maybe just try again next time. Sometimes the model just doesn't know, it's not perfect. And the GUI might be broken on macOS.

lukas-blecher commented 2 years ago

What pytorch version do you have installed?

mailanmi commented 2 years ago

Thank you for your reply.

My pytorch version is 1.11.0.

When it comes to the errors, I tried to run the program multiple times, but every time I got the same error (as attached in the previous message).