Spaces:
Running
Running
| import streamlit as st | |
| from transformers import pipeline | |
| # Title | |
| st.title("๐ Text Summarizer") | |
| st.write("Paste your text below and get a short summary!") | |
| # Text input | |
| user_input = st.text_area("Enter text here:", height=200) | |
| # Load summarization pipeline | |
| @st.cache_resource | |
| def load_model(): | |
| return pipeline("summarization", model="facebook/bart-large-cnn") | |
| summarizer = load_model() | |
| # Summarize button | |
| if st.button("Summarize"): | |
| if user_input.strip() == "": | |
| st.warning("Please enter some text first!") | |
| else: | |
| summary = summarizer(user_input, max_length=100, min_length=25, do_sample=False) | |
| st.success(summary[0]['summary_text']) |