Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
</script>
|
13 |
-
<p>
|
14 |
-
$$ {latex_str} $$
|
15 |
-
</p>
|
16 |
-
</body>
|
17 |
-
</html>
|
18 |
-
"""
|
19 |
|
20 |
-
iface = gr.Interface(fn=
|
21 |
inputs="text",
|
22 |
-
outputs="
|
23 |
-
|
24 |
-
|
25 |
|
26 |
iface.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
import tempfile
|
4 |
+
import os
|
5 |
|
6 |
+
def latex_to_image(latex_str):
|
7 |
+
# LaTeX 문자열을 이미지로 변환
|
8 |
+
fig, ax = plt.subplots()
|
9 |
+
ax.text(0.5, 0.5, f'${latex_str}$', fontsize=15, ha='center', va='center')
|
10 |
+
ax.axis('off')
|
11 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmpfile:
|
12 |
+
plt.savefig(tmpfile.name, bbox_inches='tight', pad_inches=0.1)
|
13 |
+
plt.close(fig)
|
14 |
+
return tmpfile.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
iface = gr.Interface(fn=latex_to_image,
|
17 |
inputs="text",
|
18 |
+
outputs="image",
|
19 |
+
title="LaTeX to Image Renderer",
|
20 |
+
description="Enter a LaTeX string to render it as an image.")
|
21 |
|
22 |
iface.launch(share=True)
|