Spaces:
Runtime error
Runtime error
YumingYuan
commited on
Commit
•
9889f60
1
Parent(s):
e0c356c
Demo
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from pix2tex.cli import LatexOCR
|
4 |
+
|
5 |
+
# Receives an image and returns the latex code and the markdown code
|
6 |
+
def img_latex(image):
|
7 |
+
img = Image.open(image)
|
8 |
+
model = LatexOCR()
|
9 |
+
latex = model(img)
|
10 |
+
markdown = latex
|
11 |
+
markdown = r'$$' + latex + r'$$'
|
12 |
+
return latex, markdown
|
13 |
+
|
14 |
+
|
15 |
+
gr.Interface(
|
16 |
+
img_latex,
|
17 |
+
inputs=gr.inputs.Image(label="Upload", type="filepath"),
|
18 |
+
outputs=[gr.outputs.Textbox(label="Latex"),gr.outputs.Textbox(label="Markdown")],
|
19 |
+
title="Latex OCR",
|
20 |
+
).launch()
|