Spaces:
Runtime error
Runtime error
urls
Browse files
app.py
CHANGED
@@ -20,11 +20,16 @@ examples = [
|
|
20 |
]
|
21 |
|
22 |
title = "Upword - Models Competition"
|
23 |
-
description = "This demo compares [BART-Large-CNN](https://huggingface.co/facebook/bart-large-cnn) and [Flan-T5-
|
24 |
|
25 |
-
url = os.environ["url"]
|
26 |
token = os.environ["token"]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
def inference(text):
|
30 |
headers = {"Authorization": f"Bearer {token}"}
|
@@ -36,9 +41,12 @@ def inference(text):
|
|
36 |
"do_sample": False
|
37 |
}
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
42 |
return [output_flan, output_vanilla]
|
43 |
|
44 |
|
@@ -46,8 +54,8 @@ io = gr.Interface(
|
|
46 |
inference,
|
47 |
gr.Textbox(lines=3),
|
48 |
outputs=[
|
49 |
-
gr.Textbox(lines=3, label="Flan T5"),
|
50 |
-
gr.Textbox(lines=3, label="
|
51 |
],
|
52 |
title=title,
|
53 |
description=description,
|
|
|
20 |
]
|
21 |
|
22 |
title = "Upword - Models Competition"
|
23 |
+
description = "This demo compares [BART-Large-CNN](https://huggingface.co/facebook/bart-large-cnn) and [Flan-T5-XXL](https://huggingface.co/google/flan-t5-xxl)."
|
24 |
|
|
|
25 |
token = os.environ["token"]
|
26 |
|
27 |
+
urls = {
|
28 |
+
'flan-t5': os.environ["url"],
|
29 |
+
# 'flan-t5': "https://api-inference.huggingface.co/models/philschmid/flan-t5-xxl-sharded-fp16",
|
30 |
+
'bart-large-cnn': "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
|
31 |
+
}
|
32 |
+
|
33 |
|
34 |
def inference(text):
|
35 |
headers = {"Authorization": f"Bearer {token}"}
|
|
|
41 |
"do_sample": False
|
42 |
}
|
43 |
}
|
44 |
+
responses = dict()
|
45 |
+
for model, url in urls.items():
|
46 |
+
responses[model] = requests.post(url, headers=headers, json=payload)
|
47 |
+
|
48 |
+
output_flan = responses['flan-t5'].json()[0]['generated_text']
|
49 |
+
output_vanilla = responses['bart-large-cnn'].json()[0]['summary_text']
|
50 |
return [output_flan, output_vanilla]
|
51 |
|
52 |
|
|
|
54 |
inference,
|
55 |
gr.Textbox(lines=3),
|
56 |
outputs=[
|
57 |
+
gr.Textbox(lines=3, label="Flan T5-XXL"),
|
58 |
+
gr.Textbox(lines=3, label="BART-Large-CNN")
|
59 |
],
|
60 |
title=title,
|
61 |
description=description,
|