Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,24 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
3 |
-
import tempfile
|
4 |
-
import shutil
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# LaTeX
|
13 |
-
|
14 |
-
|
15 |
-
plt.axis('off')
|
16 |
-
plt.text(0.5, 0.5, f'${latex_code}$', ha='center', va='center', fontsize=20)
|
17 |
-
plt.savefig(temp_file_name, bbox_inches='tight', pad_inches=0.1)
|
18 |
-
plt.close()
|
19 |
-
|
20 |
-
# ์์ ์ด๋ฏธ์ง ํ์ผ ๊ฒฝ๋ก ๋ฐํ
|
21 |
-
return temp_file_name
|
22 |
|
23 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
24 |
-
iface = gr.Interface(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
|
30 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
31 |
iface.launch()
|
|
|
1 |
+
import requests
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
4 |
+
def render_latex_to_image(latex_str):
|
5 |
+
"""
|
6 |
+
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์
๋ ฅ์ ๋ฐ์์ CodeCogs LaTeX API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง๋ก ๋ณํํ๊ณ ,
|
7 |
+
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์
|
8 |
+
"""
|
9 |
+
encoded_str = requests.utils.quote(latex_str) # URL์ ํฌํจ์ํฌ ์ ์๋๋ก LaTeX ๋ฌธ์์ด ์ธ์ฝ๋ฉ
|
10 |
+
# CodeCogs LaTeX ๋ ๋๋ง ์๋น์ค URL ์์ฑ
|
11 |
+
url = f"https://latex.codecogs.com/png.latex?{encoded_str}"
|
12 |
+
return url # ์์ฑ๋ ์ด๋ฏธ์ง์ URL์ ๋ฐํ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=render_latex_to_image,
|
17 |
+
inputs=gr.Textbox(placeholder="Enter LaTeX code here...", lines=4),
|
18 |
+
outputs=gr.Image(),
|
19 |
+
title="LaTeX to Image Renderer",
|
20 |
+
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API."
|
21 |
+
)
|
22 |
|
23 |
# Gradio ์ธํฐํ์ด์ค ์คํ
|
24 |
iface.launch()
|