ocrlatex / app.py
seawolf2357's picture
Update app.py
ca60e9b verified
raw
history blame
755 Bytes
import gradio as gr
import matplotlib.pyplot as plt
import tempfile
import os
def latex_to_image(latex_str):
# LaTeX 문자열을 이미지로 변환
fig, ax = plt.subplots()
ax.text(0.5, 0.5, f'${latex_str}$', fontsize=15, ha='center', va='center')
ax.axis('off')
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmpfile:
plt.savefig(tmpfile.name, bbox_inches='tight', pad_inches=0.1)
plt.close(fig)
return tmpfile.name
iface = gr.Interface(fn=latex_to_image,
inputs="text",
outputs="image",
title="LaTeX to Image Renderer",
description="Enter a LaTeX string to render it as an image.")
iface.launch(share=True)