File size: 538 Bytes
7365c36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from PIL import Image
from pix2tex.cli import LatexOCR

# Receives an image and returns the latex code and the markdown code
def img_latex(image):
    img = Image.open(image)
    model = LatexOCR()
    latex = model(img)
    markdown = latex
    markdown = r'$$' + latex + r'$$'
    return latex, markdown


gr.Interface(
    img_latex,
    inputs=gr.inputs.Image(label="Upload", type="filepath"),
    outputs=[gr.outputs.Textbox(label="Latex"),gr.outputs.Textbox(label="Markdown")],
    title="Latex OCR",
).launch()