820nam commited on
Commit
8d09e05
ยท
verified ยท
1 Parent(s): e4be2da

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -0
main.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # ๊ฐ์ • ๋ถ„์„ ๋ชจ๋ธ์„ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.
5
+ classifier = pipeline("sentiment-analysis")
6
+
7
+ # ์˜ˆ์ธก ํ•จ์ˆ˜ ์ •์˜
8
+ def sentiment_analysis(text):
9
+ result = classifier(text)[0]
10
+ label = result['label']
11
+ score = result['score']
12
+ return f"Label: {label}, Score: {score:.2f}"
13
+
14
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
15
+ iface = gr.Interface(
16
+ fn=sentiment_analysis,
17
+ inputs="text",
18
+ outputs="text",
19
+ title="Sentiment Analysis",
20
+ description="Enter text to analyze its sentiment.",
21
+ )
22
+
23
+ # ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰
24
+ iface.launch()