File size: 853 Bytes
ec5aa0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_pipeline = pipeline("sentiment-analysis")

def analyze_sentiment(text):
    # μž…λ ₯된 ν…μŠ€νŠΈμ— λŒ€ν•œ 감정 뢄석을 μˆ˜ν–‰ν•©λ‹ˆλ‹€.
    result = sentiment_pipeline(text)
    # 뢄석 κ²°κ³Όλ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
    return result[0]

# Gradio μΈν„°νŽ˜μ΄μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
interface = gr.Interface(fn=analyze_sentiment,
                         inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
                         outputs="json",
                         title="Text Sentiment Analysis",
                         description="Enter a piece of text to analyze its sentiment. The model will classify it as positive or negative.")

# 앱을 μ‹€ν–‰ν•©λ‹ˆλ‹€.
if __name__ == "__main__":
    interface.launch()