Spaces:
Runtime error
Runtime error
Download app.py from cronin2021/my-first-app: direct link, hf CLI and curl.
- Browser
- Download file 917 Bytes
-
https://huggingface.co/spaces/cronin2021/my-first-app/resolve/main/app.py
- Command line
-
hf download hf://spaces/cronin2021/my-first-app/app.py
-
curl -L -o app.py https://huggingface.co/spaces/cronin2021/my-first-app/resolve/main/app.py
917 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the summarization model (it will download automatically) | |
| summarizer = pipeline("summarization", model="facebook/bart-large-cnn") | |
| # Define a function that takes text and returns a summary | |
| def summarize_text(text): | |
| if len(text.strip()) == 0: | |
| return "Please enter some text to summarize." | |
| # Summarize! | |
| summary = summarizer(text, max_length=130, min_length=30, do_sample=False) | |
| return summary[0]['summary_text'] | |
| # Create the Gradio interface | |
| demo = gr.Interface( | |
| fn=summarize_text, | |
| inputs=gr.Textbox( | |
| placeholder="Enter text here to summarize...", | |
| lines=8, | |
| label="Input Text" | |
| ), | |
| outputs=gr.Textbox(label="Summary"), | |
| title="📝 AI Text Summarizer", | |
| description="Paste any article, email, or text and get a concise summary instantly!", | |
| theme="soft" | |
| ) | |
| # Launch the app | |
| demo.launch() |