fabianad commited on
Commit
765459d
·
verified ·
1 Parent(s): ecf2f35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -6
app.py CHANGED
@@ -1,7 +1,27 @@
 
1
  import gradio as gr
2
- title = 'Text Summarization'
3
- text_ = "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."
4
- interface = gr.Interface.load("huggingface/facebook/bart-large-cnn",
5
- title = title,
6
- theme = "peach",
7
- examples = [[text_]]).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary libraries
2
  import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Load the summarization model
6
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
7
+
8
+ # Define the function to summarize text
9
+ def summarize_text(text):
10
+ if not text.strip():
11
+ return "Please enter some text to summarize."
12
+
13
+ summary = summarizer(text, max_length=150, min_length=30, do_sample=False)
14
+ return summary[0]["summary_text"]
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=summarize_text,
19
+ inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
20
+ outputs="text",
21
+ title="Text Summarization Chatbot",
22
+ description="Enter a long text passage, and the chatbot will summarize it for you using the 'facebook/bart-large-cnn' model.",
23
+ theme="compact"
24
+ )
25
+
26
+ # Launch the app
27
+ iface.launch()