Spaces:
Running
Running
File size: 755 Bytes
282ba81 ca60e9b 282ba81 ca60e9b 282ba81 ca60e9b 77c47bb ca60e9b 282ba81 77c47bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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) |