Spaces:
Build error
Build error
Download app.py from MohsinRazzaq/Text_Summarization_App: direct link, hf CLI and curl.
- Browser
- Download file 924 Bytes
-
https://huggingface.co/spaces/MohsinRazzaq/Text_Summarization_App/resolve/main/app.py
- Command line
-
hf download hf://spaces/MohsinRazzaq/Text_Summarization_App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MohsinRazzaq/Text_Summarization_App/resolve/main/app.py
924 Bytes
| # from transformers import pipeline | |
| # # Load the summarization pipeline | |
| # summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| from transformers import pipeline | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn", framework="pt") | |
| def summarize_text(input_text): | |
| # Perform summarization | |
| summary = summarizer(input_text, max_length=130, min_length=30, do_sample=False) | |
| return summary[0]['summary_text'] | |
| import gradio as gr | |
| # Define Gradio interface | |
| interface = gr.Interface( | |
| fn=summarize_text, # Function to summarize | |
| inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."), # Input box | |
| outputs="text", # Output box | |
| title="Text Summarizer", # App title | |
| description="Paste a long paragraph or article, and this app will summarize it into a concise version." | |
| ) | |
| # Launch the interface | |
| interface.launch() | |