File size: 884 Bytes
b8f6eea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

# ๊ฐ์„ฑ ๋ถ„์„ ํŒŒ์ดํ”„๋ผ์ธ ์ดˆ๊ธฐํ™”
sentiment = pipeline("sentiment-analysis")

# ์‚ฌ์šฉ์ž ์ž…๋ ฅ์— ๋Œ€ํ•œ ๊ฐ์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
def get_sentiment(์ž…๋ ฅ):
    # ๊ฐ์„ฑ ๋ถ„์„ ์‹คํ–‰
    result = sentiment(์ž…๋ ฅ)
    # ๊ฒฐ๊ณผ ํฌ๋งทํŒ… ๋ฐ ๋ฐ˜ํ™˜
    return result[0]

# Gradio ์•ฑ ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ
iface = gr.Interface(
    fn=get_sentiment,  # ์‹คํ–‰ํ•  ํ•จ์ˆ˜
    inputs=gr.inputs.Textbox(lines=2, placeholder="์—ฌ๊ธฐ์— ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."),  # ์ž…๋ ฅ๋ž€ ์„ค์ •
    outputs="json",  # ์ถœ๋ ฅ ํ˜•ํƒœ
    clear_on_submit=True,  # ์ œ์ถœ ํ›„ ์ž…๋ ฅ๋ž€ ํด๋ฆฌ์–ด
    title="ํ…์ŠคํŠธ ๊ฐ์„ฑ ๋ถ„์„",  # UI ์ œ๋ชฉ
    description="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ œ์ถœ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ ๊ฐ์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ํ™•์ธํ•˜์„ธ์š”."  # UI ์„ค๋ช…
)

# Gradio ์•ฑ ์‹คํ–‰
iface.launch()