Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,50 +1,28 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from transformers import AutoTokenizer, AutoModelWithLMHead, AutoModelForSeq2SeqLM
|
4 |
-
|
5 |
-
title = "Text Summarizer"
|
6 |
-
description = "Past an article text or other text. Submit the text and the machine will create four summaries based on words in the text. Which sentences in the text are the most important for the summaries? Which summaries are better for your case?"
|
7 |
-
examples = [
|
8 |
-
|
9 |
-
["""""""""
|
10 |
-
Hong Kong health authorities on Wednesday began a city-wide search for the contacts of a Covid-19 patient from a suspected dance cluster and ordered a Royal Caribbean "cruise to nowhere" ship with 3,700 people onboard to return to port early.
|
11 |
-
|
12 |
-
The latest hunt was sparked by a 62-year-old woman who danced with some 20 friends at Victoria Park and the Causeway Bay Community Centre on New Year's Eve. Two of the fellow dancers, one of whom was a domestic helper, came up positive in preliminary tests.
|
13 |
-
|
14 |
-
The 62-year-old was said to have contracted the virus from her 28-year-old flight attendant daughter, who returned to Hong Kong on December 27 and had onset of symptoms on December 29.
|
15 |
-
|
16 |
-
It was only on January 1 that the 62-year-old was classified as a close contact and being brought to a quarantine facility.
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
As part of its coronavirus restrictions, Hong Kong has restricted cruises to short trips in nearby waters, with ships asked to operate at reduced capacity and to only allow vaccinated passengers who test negative for the virus.
|
21 |
-
|
22 |
-
The "Spectrum of the Seas" ship had about 2,500 passengers and 1,200 staff on board. The nine close contact passengers were isolated from the rest of the people on board and preliminary tests taken during the journey returned negative results, authorities said.
|
23 |
-
|
24 |
-
"Spectrum of the Seas is taking appropriate measures under guidelines by the Department of Health," Royal Caribbean said in a statement.
|
25 |
-
|
26 |
-
The ship was on early Wednesday ordered to return to the Kai Tak Cruise Terminal. The nine close contacts will be sent to a quarantine center, while the rest of the passengers and staff will have to undergo several compulsory tests in the coming days, the government said.
|
27 |
-
"""""""""],
|
28 |
-
["""""
|
29 |
-
Hong Kong has seen a record low in the Joint University Programmes Admissions System this year, the lowest in nearly a decade.
|
30 |
-
|
31 |
-
JUPAS - the main route to apply for local tertiary institutions - allows applicants to seek entry to full-time programs at the eight institutions funded by the University Grants Committee and the self-financed Hong Kong Metropolitan University.
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
-
|
38 |
-
""
|
39 |
-
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
io3 = gr.Interface.load("huggingface/csebuetnlp/mT5_multilingual_XLSum")
|
44 |
-
io4 = gr.Interface.load("huggingface/google/pegasus-xsum")
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
|
|
1 |
+
# Step 2: Install the latest version of Gradio
|
2 |
+
!pip install gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
+
# Step 3: Verify the installation
|
5 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
print("Gradio version:", gr.__version__)
|
8 |
|
9 |
+
# Step 4: Define the Gradio interface using the latest API
|
10 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
11 |
|
12 |
+
def summarize(text):
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-large-cnn")
|
14 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large-cnn")
|
15 |
+
inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=1024, truncation=True)
|
16 |
+
summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
|
17 |
+
return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
18 |
|
19 |
+
iface1 = gr.Interface(fn=summarize, inputs="textbox", outputs="textbox", title="Text Summarizer")
|
20 |
+
iface2 = gr.Interface(fn=summarize, inputs="textbox", outputs="textbox", title="Text Summarizer")
|
|
|
|
|
21 |
|
22 |
+
# Combine interfaces using the latest Gradio Blocks API
|
23 |
+
with gr.Blocks() as demo:
|
24 |
+
with gr.Row():
|
25 |
+
iface1.render()
|
26 |
+
|
27 |
|
28 |
+
demo.launch()
|