MatthewBurke1995 commited on
Commit
0734723
Β·
1 Parent(s): 3c97624

Add application file

Browse files
Files changed (1) hide show
  1. app.py +21 -0
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
+