Skip to content

Commit dd847d2

Browse files
Update README.md
Clear things up #259 #238
1 parent 2edd957 commit dd847d2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ There are three ways to get a prediction from an image.
4646
```
4747
and navigate to http://localhost:8501/
4848

49+
4. Use from within Python
50+
```python
51+
from PIL import Image
52+
from pix2tex.cli import LatexOCR
53+
54+
img = Image.open('path/to/image.png')
55+
model = LatexOCR()
56+
print(model(img))
57+
```
58+
4959
The model works best with images of smaller resolution. That's why I added a preprocessing step where another neural network predicts the optimal resolution of the input image. This model will automatically resize the custom image to best resemble the training data and thus increase performance of images found in the wild. Still it's not perfect and might not be able to handle huge images optimally, so don't zoom in all the way before taking a picture.
5060
5161
Always double check the result carefully. You can try to redo the prediction with an other resolution if the answer was wrong.

0 commit comments

Comments
 (0)