Spaces:
Runtime error
Runtime error
Ahsen Khaliq
commited on
Commit
·
4f4765f
1
Parent(s):
fbbe9ec
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,12 +7,31 @@ description = "Gradio Demo for BART, to use it, simply add your text, or click o
|
|
| 7 |
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>"
|
| 8 |
|
| 9 |
examples = [
|
| 10 |
-
["I have a problem with my iphone that needs to be resolved asap!!","urgent, not urgent, phone, tablet, computer",
|
| 11 |
]
|
| 12 |
|
| 13 |
-
gr.Interface.load("huggingface/facebook/bart-large-mnli")
|
| 14 |
-
|
| 15 |
-
gr.Interface.load("huggingface/facebook/facebook/bart-large-cnn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
|
|
|
|
| 7 |
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>"
|
| 8 |
|
| 9 |
examples = [
|
| 10 |
+
["I have a problem with my iphone that needs to be resolved asap!!","bart-large-mnli","urgent, not urgent, phone, tablet, computer",False]
|
| 11 |
]
|
| 12 |
|
| 13 |
+
io1 = gr.Interface.load("huggingface/facebook/bart-large-mnli")
|
| 14 |
+
|
| 15 |
+
io2 = gr.Interface.load("huggingface/facebook/facebook/bart-large-cnn")
|
| 16 |
+
|
| 17 |
+
def inference(text, model,class_names,allow_multiple):
|
| 18 |
+
if model == "bart-large-mnli":
|
| 19 |
+
outlabel = io1(text,class_names,allow_multiple)
|
| 20 |
+
outtext = ""
|
| 21 |
+
else:
|
| 22 |
+
outtext = io2(text)
|
| 23 |
+
outlabel = {}
|
| 24 |
+
return outlabel, outtext
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
gr.Interface(
|
| 28 |
+
inference,
|
| 29 |
+
[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")],
|
| 30 |
+
["label","textbox"],
|
| 31 |
+
examples=examples,
|
| 32 |
+
article=article,
|
| 33 |
+
title=title,
|
| 34 |
+
description=description).launch(enable_queue=True, cache_examples=True)
|
| 35 |
|
| 36 |
|
| 37 |
|