File size: 681 Bytes
748571c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

# 'sentiment-analysis' νŒŒμ΄ν”„λΌμΈ μ΄ˆκΈ°ν™”
sentiment = pipeline('sentiment-analysis')

# 감성 뢄석을 μˆ˜ν–‰ν•˜λŠ” ν•¨μˆ˜ μ •μ˜
def get_sentiment(text):
    result = sentiment(text)
    return result[0]

# Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
interface = gr.Interface(fn=get_sentiment,
                         inputs=gr.inputs.Textbox(lines=2, placeholder="Type your text here..."),
                         outputs='json',
                         title="Sentiment Analysis",
                         description="Enter text to analyze sentiment.")

# Gradio μ•± μ‹€ν–‰
if __name__ == "__main__":
    interface.launch()