Spaces:
Runtime error
Runtime error
File size: 2,311 Bytes
920b32a 5929287 920b32a a87cff7 920b32a 5929287 4f4765f 8a00486 4f4765f ca67594 4f4765f 9b97643 4f4765f d299bd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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],
["The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.","bart-large-cnn","None",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 = {"none":"none"}
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")],
[gr.outputs.Label(label="Zero-Shot Classification"),gr.outputs.Textbox(label="Summarization")],
examples=examples,
article=article,
title=title,
description=description).launch(enable_queue=True)
|