Spaces:
Running
Running
File size: 912 Bytes
73b4995 282ba81 27249d8 73b4995 27249d8 73b4995 32eac0f 088654a 27249d8 73b4995 27249d8 282ba81 088654a 6e98020 |
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 |
import urllib.parse
import gradio as gr
def render_latex_to_image(latex_str):
"""
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์
๋ ฅ์ ๋ฐ์์ Codecogs LaTeX Rendering API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง(png ํ์)๋ก ๋ณํํ๊ณ ,
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์
"""
base_url = "https://latex.codecogs.com/png.latex?"
# LaTeX ๋ฌธ์์ด์ URL ์ธ์ฝ๋ฉ
encoded_str = urllib.parse.quote(latex_str)
# ์ต์ข
์ด๋ฏธ์ง URL ์์ฑ
image_url = f"{base_url}{encoded_str}"
return image_url
# Gradio ์ธํฐํ์ด์ค ์ ์
iface = gr.Interface(
fn=render_latex_to_image,
inputs=gr.Textbox(placeholder="Enter LaTeX code here...", lines=4),
outputs=gr.Image(),
title="LaTeX to Image Renderer with CodeCogs API",
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API."
)
# Gradio ์ธํฐํ์ด์ค ์คํ
iface.launch() |