deberta-v3-zc / app.py
hesha's picture
Update app.py
187b1c6 verified
raw
history blame
729 Bytes
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)
print(output)
return dict(zip(output['labels'], output['scores']))
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()