Spaces:
Running
Running
File size: 1,011 Bytes
282ba81 5d72210 282ba81 f5d8dcc 5d72210 f5d8dcc 32eac0f f5d8dcc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import gradio as gr
import requests
# Mathpix ์์ฒญ์ ์ํ ํจ์
def process_image_to_latex(file_path):
headers = {
"app_id": "arxivgpt_2c0986",
"app_key": "b5c14c78ea645a6d673195e6360a1cc33ef2bab7a79b90f7cebf6465177171f5",
"Content-type": "application/json"
}
with open(file_path, "rb") as file:
img_data = file.read()
response = requests.post(
"https://api.mathpix.com/v3/latex",
headers=headers,
json={"src": "data:image/jpeg;base64," + base64.b64encode(img_data).decode()}
)
return response.json()["latex"]
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
def create_gradio_interface():
with gr.Blocks() as demo:
gr.Markdown("## LaTeX ์ถ์ถ๊ธฐ")
file_input = gr.File(label="์ด๋ฏธ์ง ๋๋ PDF ํ์ผ ์
๋ก๋")
latex_output = gr.Textbox(label="์ถ์ถ๋ LaTeX")
file_input.change(fn=process_image_to_latex, inputs=[file_input], outputs=[latex_output])
demo.launch()
create_gradio_interface()
|