Spaces:
Runtime error
Runtime error
File size: 909 Bytes
27249d8 282ba81 27249d8 32eac0f 088654a 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 |
import requests
import gradio as gr
def render_latex_to_image(latex_str):
"""
์ฌ์ฉ์์ LaTeX ๋ฌธ์์ด ์
๋ ฅ์ ๋ฐ์์ CodeCogs LaTeX API๋ฅผ ์ด์ฉํด ์ด๋ฏธ์ง๋ก ๋ณํํ๊ณ ,
์์ฑ๋ ์ด๋ฏธ์ง URL์ ๋ฐํํ๋ ํจ์
"""
encoded_str = requests.utils.quote(latex_str) # URL์ ํฌํจ์ํฌ ์ ์๋๋ก LaTeX ๋ฌธ์์ด ์ธ์ฝ๋ฉ
# CodeCogs LaTeX ๋ ๋๋ง ์๋น์ค URL ์์ฑ
url = f"https://latex.codecogs.com/png.latex?{encoded_str}"
return url # ์์ฑ๋ ์ด๋ฏธ์ง์ 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",
description="Enter LaTeX code to render it into an image using the CodeCogs LaTeX Rendering API."
)
# Gradio ์ธํฐํ์ด์ค ์คํ
iface.launch() |