File size: 672 Bytes
dac603c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline

model = 'MoritzLaurer/deberta-v3-base-zeroshot-v1.1-all-33'
pipe = pipeline('zero-shot-classification', model=model)

def infer(text, classes, multi_label):
    output = pipe(text, classes, multi_label=multi_label)
    return output

text_input = gr.Textbox(lines=5, placeholder='Once upon a time...', label='Text Source', show_label=True)
class_input = gr.Textbox(value='positive,negative', label='Class Label', show_label=True)
allow_multi_label = gr.Checkbox(value=True, label='Multiple True Classes')

app = gr.Interface(fn=infer, inputs=[text_input, class_input, allow_multi_label], outputs='label')
app.launch()