Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# ๊ฐ์ฑ ๋ถ์ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
|
| 5 |
+
sentiment = pipeline("sentiment-analysis")
|
| 6 |
+
|
| 7 |
+
# ์ฌ์ฉ์ ์
๋ ฅ์ ๋ํ ๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ํจ์
|
| 8 |
+
def get_sentiment(์
๋ ฅ):
|
| 9 |
+
# ๊ฐ์ฑ ๋ถ์ ์คํ
|
| 10 |
+
result = sentiment(์
๋ ฅ)
|
| 11 |
+
# ๊ฒฐ๊ณผ ํฌ๋งทํ
๋ฐ ๋ฐํ
|
| 12 |
+
return result[0]
|
| 13 |
+
|
| 14 |
+
# Gradio ์ฑ ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=get_sentiment, # ์คํํ ํจ์
|
| 17 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="์ฌ๊ธฐ์ ํ
์คํธ๋ฅผ ์
๋ ฅํ์ธ์..."), # ์
๋ ฅ๋ ์ค์
|
| 18 |
+
outputs="json", # ์ถ๋ ฅ ํํ
|
| 19 |
+
clear_on_submit=True, # ์ ์ถ ํ ์
๋ ฅ๋ ํด๋ฆฌ์ด
|
| 20 |
+
title="ํ
์คํธ ๊ฐ์ฑ ๋ถ์", # UI ์ ๋ชฉ
|
| 21 |
+
description="ํ
์คํธ๋ฅผ ์
๋ ฅํ๊ณ ์ ์ถ ๋ฒํผ์ ํด๋ฆญํ์ฌ ๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํ์ธ์." # UI ์ค๋ช
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Gradio ์ฑ ์คํ
|
| 25 |
+
iface.launch()
|