File size: 434 Bytes
7a87b77
 
 
7bb17c0
7a87b77
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr 
from transformers import pipeline
 
pipe = pipeline("text-classification","uer/roberta-base-finetuned-jd-binary-chinese")
 
def clf(text):
    result = pipe(text)
    label = result[0]['label']
    score = result[0]['score']
    res = {label:score,'POSITIVE' if label=='NEGATIVE' else 'NEGATIVE': 1-score}
    return res 
 
demo = gr.Interface(fn=clf, inputs="text", outputs="label")
gr.close_all()
demo.launch()