kijeoung commited on
Commit
8e89617
ยท
verified ยท
1 Parent(s): 0e576f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # ๊ฐ์ • ๋ถ„์„ ๋ชจ๋ธ ๋กœ๋“œ
5
+ emotion_analyzer = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
6
+
7
+ # ์˜ˆ์ธก ํ•จ์ˆ˜
8
+ def analyze_emotion(text):
9
+ result = emotion_analyzer(text)[0]
10
+ label = result['label']
11
+ score = result['score'] * 100
12
+ return f"{label}, {score:.2f}%"
13
+
14
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
15
+ interface = gr.Interface(
16
+ fn=analyze_emotion, # ๋ถ„์„ ํ•จ์ˆ˜
17
+ inputs=gr.Textbox(lines=2, placeholder="ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”..."), # ์ž…๋ ฅ
18
+ outputs="text", # ์ถœ๋ ฅ
19
+ title="๊ฐ์ • ๋ถ„์„ ์•ฑ",
20
+ description="์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ํ…์ŠคํŠธ์˜ ๊ฐ์ •์„ ๋ถ„์„ํ•˜์—ฌ ๋ ˆ์ด๋ธ”๊ณผ ํ™•๋ฅ ๊ฐ’์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค."
21
+ )
22
+
23
+ # ์‹คํ–‰
24
+ if __name__ == "__main__":
25
+ interface.launch()