Spaces:
Sleeping
Sleeping
| import torch | |
| import transformers | |
| import gradio as gr | |
| from transformers import pipeline | |
| summarizer = pipeline(task="summarization", model="facebook/bart-large-cnn") | |
| text = """Paris is the capital and most populous city of France, with | |
| an estimated population of 2,175,601 residents as of 2018, | |
| in an area of more than 105 square kilometres (41 square | |
| miles). The City of Paris is the centre and seat of | |
| government of the region and province of Île-de-France, or | |
| Paris Region, which has an estimated population of | |
| 12,174,880, or about 18 percent of the population of France | |
| as of 2017.""" | |
| summary = summarizer(text, min_length=10, max_length=100) | |
| summary | |
| summary=summary[0]['summary_text'] | |
| print(summary) | |
| def summarization(text): | |
| text = summary | |
| return text | |
| # Create the Gradio interface | |
| iface = gr.Interface( | |
| fn=summarization, | |
| inputs=gr.Textbox(placeholder="Enter text to summarize..."), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="Bart Summarization Model", | |
| description="Enter a text or a paragraph to summarize its content: ", | |
| ) | |
| # Launch the app | |
| if __name__ == "__main__": | |
| iface.launch() |