Spaces:
Sleeping
Sleeping
Create gradio.py
Browse files
gradio.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# ๊ฐ์ฑ ๋ถ์ ๋ชจ๋ธ์ ๋ถ๋ฌ์ต๋๋ค.
|
5 |
+
sentiment = pipeline('sentiment-analysis')
|
6 |
+
|
7 |
+
def get_sentiment(input_text):
|
8 |
+
# ์
๋ ฅ ํ
์คํธ์ ๊ฐ์ฑ์ ๋ถ์ํฉ๋๋ค.
|
9 |
+
result = sentiment(input_text)[0]
|
10 |
+
label = result['label']
|
11 |
+
score = result['score']
|
12 |
+
return f"๊ฐ์ฑ: {label}, ์ ๋ขฐ๋: {score}"
|
13 |
+
|
14 |
+
# Gradio UI๋ฅผ ์ค์ ํฉ๋๋ค.
|
15 |
+
input_text = gr.inputs.Textbox(lines=7, label="ํ
์คํธ ์
๋ ฅ")
|
16 |
+
output_text = gr.outputs.Textbox(label="๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ")
|
17 |
+
|
18 |
+
# Gradio ์ธํฐํ์ด์ค๋ฅผ ์์ฑํฉ๋๋ค.
|
19 |
+
gr.Interface(get_sentiment, inputs=input_text, outputs=output_text).launch()
|