bart-large-mnli / app.py
Ahsen Khaliq
Update app.py
8a00486
raw
history blame
1.46 kB
import gradio as gr
title = "BART"
description = "Gradio Demo for BART, to use it, simply add your text, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1910.13461' target='_blank'>BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension</a></p>"
examples = [
["I have a problem with my iphone that needs to be resolved asap!!","bart-large-mnli","urgent, not urgent, phone, tablet, computer",False]
]
io1 = gr.Interface.load("huggingface/facebook/bart-large-mnli")
io2 = gr.Interface.load("huggingface/facebook/bart-large-cnn")
def inference(text, model,class_names,allow_multiple):
if model == "bart-large-mnli":
outlabel = io1(text,class_names,allow_multiple)
outtext = ""
else:
outtext = io2(text)
outlabel = {}
return outlabel, outtext
gr.Interface(
inference,
[gr.inputs.Textbox(label="Input",lines=10),gr.inputs.Dropdown(choices=["bart-large-mnli","bart-large-cnn"], type="value", default="bart-large-mnli", label="model"),gr.inputs.Textbox(label="Possible class names (comma-separated)"),gr.inputs.Checkbox(default=False, label="Allow multiple true classes")],
["label","textbox"],
examples=examples,
article=article,
title=title,
description=description).launch(enable_queue=True, cache_examples=True)