Spaces:
Runtime error
Runtime error
MatthewBurke1995
commited on
Commit
Β·
0734723
1
Parent(s):
3c97624
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
classifier = pipeline("text-classification", model="matthewburke/korean_sentiment")
|
| 6 |
+
|
| 7 |
+
def predict(text):
|
| 8 |
+
result = classifier(text, return_all_scores=True)[0]
|
| 9 |
+
positive_score = result[1]['score']
|
| 10 |
+
negative_score = result[0]['score']
|
| 11 |
+
return {"positive": positive_score, "negative": negative_score}
|
| 12 |
+
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=predict,
|
| 15 |
+
inputs='text',
|
| 16 |
+
outputs='label',
|
| 17 |
+
examples=[["μνκ° μ¬λ°μλ€"]]
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|
| 21 |
+
|