Faizan15 commited on
Commit
fc2c13a
·
1 Parent(s): bec50de

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe = pipeline("text-classification","uer/roberta-base-finetuned-jd-binary-chinese")
5
+
6
+ def clf(text):
7
+ result = pipe(text)
8
+ label = result[0]['label']
9
+ score = result[0]['score']
10
+ res = {label:score,'positive' if label.startswith('negative') else 'negative': 1-score}
11
+ return res
12
+
13
+ demo = gr.Interface(fn=clf, inputs=gr.Textbox(label="输入文本"), outputs=gr.Label(label="输出结果"))
14
+ gr.close_all()
15
+ demo.launch()