Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| #function of summarize | |
| def summarize_text(text): | |
| summary = summarizer(text, max_length=100, min_length=10, do_sample=False) | |
| return summary[0]['summary_text'] | |
| #gradio interface | |
| demo = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox(label="Enter your text:", lines=10, placeholder="Paste a paragraph here..."), | |
| outputs=gr.Textbox(label="Summarized Text", lines=3), | |
| title="Text Summarization App", | |
| ) | |
| # Launch the app | |
| if __name__ == "__main__": | |
| demo.launch() |