Spaces:
Sleeping
Sleeping
Create main.py
Browse files
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()
|