seawolf2357 commited on
Commit
ec5aa0b
β€’
1 Parent(s): 838e56a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # 감정 뢄석 νŒŒμ΄ν”„λΌμΈμ„ μƒμ„±ν•©λ‹ˆλ‹€.
5
+ sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ def analyze_sentiment(text):
8
+ # μž…λ ₯된 ν…μŠ€νŠΈμ— λŒ€ν•œ 감정 뢄석을 μˆ˜ν–‰ν•©λ‹ˆλ‹€.
9
+ result = sentiment_pipeline(text)
10
+ # 뢄석 κ²°κ³Όλ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
11
+ return result[0]
12
+
13
+ # Gradio μΈν„°νŽ˜μ΄μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
14
+ interface = gr.Interface(fn=analyze_sentiment,
15
+ inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
16
+ outputs="json",
17
+ title="Text Sentiment Analysis",
18
+ description="Enter a piece of text to analyze its sentiment. The model will classify it as positive or negative.")
19
+
20
+ # 앱을 μ‹€ν–‰ν•©λ‹ˆλ‹€.
21
+ if __name__ == "__main__":
22
+ interface.launch()