File size: 509 Bytes
0c2b6e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio
import gradio as gr

from transformers import pipeline

classifier = pipeline("zero-shot-classification", model="MoritzLaurer/deberta-v3-large-zeroshot-v1")


def classify(review, candidate_labels=('positive', 'neutral', 'negative')):
    labels = classifier(review, candidate_labels)
    return gradio.Label(label='Classification', value=(dict(zip(labels['labels'], labels['scores']))))


app = gr.Interface(fn=classify, inputs=['text'], outputs=['label'], allow_flagging="never")
app.launch()