File size: 939 Bytes
f75b944
78d8374
f75b944
78d8374
f75b944
78d8374
 
 
f75b944
78d8374
 
 
f75b944
78d8374
f75b944
 
78d8374
 
 
 
f75b944
 
 
 
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
import gradio as gr
from gradio_client import Client

def translate_text(text):
    """
    ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ํ—ˆ๊น…ํŽ˜์ด์Šค์˜ ๊ทธ๋ผ๋””์˜ค API๋ฅผ ํ†ตํ•ด ๋ฒˆ์—ญํ•ฉ๋‹ˆ๋‹ค.
    API ์—”๋“œํฌ์ธํŠธ๋Š” "Kims12/4-1_EK_translate"์ด๋ฉฐ, 
    ์ž๋™์œผ๋กœ ์˜์–ด์™€ ํ•œ๊ตญ์–ด๋ฅผ ๊ฐ์ง€ํ•˜์—ฌ ์–‘๋ฐฉํ–ฅ ๋ฒˆ์—ญ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
    """
    client = Client("Kims12/4-1_EK_translate")
    result = client.predict(text=text, api_name="/predict")
    return result

# Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
iface = gr.Interface(
    fn=translate_text,
    inputs=gr.Textbox(lines=5, placeholder="๋ฒˆ์—ญํ•  ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”.", label="์ž…๋ ฅ ํ…์ŠคํŠธ"),
    outputs=gr.Textbox(label="๋ฒˆ์—ญ ๊ฒฐ๊ณผ"),
    title="์˜์–ด-ํ•œ๊ตญ์–ด ์–‘๋ฐฉํ–ฅ ๋ฒˆ์—ญ๊ธฐ",
    description="์ž…๋ ฅํ•œ ํ…์ŠคํŠธ๋ฅผ ์˜์–ด์™€ ํ•œ๊ตญ์–ด ๊ฐ„์— ๋ฒˆ์—ญํ•ฉ๋‹ˆ๋‹ค. (ํ—ˆ๊น…ํŽ˜์ด์Šค ๊ทธ๋ผ๋””์˜ค API๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.)"
)

if __name__ == "__main__":
    iface.launch()