abstractive / app.py
Safna's picture
Update app.py
f8f49f7
import streamlit as st
from transformers import pipeline
model_name = AutoModelForSeq2SeqLM.from_pretrained("Safna/abstractive")
tokenizer_name = AutoTokenizer.from_pretrained("sshleifer/distilbart-xsum-12-3")
summarizer = pipeline("summarization", model= model_name, tokenizer= tokenizer_name)
st.title("Text Summarization App")
input_text = st.text_area("Enter the text you want to summarize:")
if st.button("Generate Summary"):
if input_text:
with st.spinner("Generating summary..."):
summary = summarizer(input_text, max_length=64, min_length=10, length_penalty=2.0, num_beams=4, early_stopping=True)
st.subheader("Generated Summary:")
st.write(summary[0]["summary_text"])
# Instructions
st.sidebar.header("Instructions")
st.sidebar.markdown("1. Enter the text you want to summarize.")
st.sidebar.markdown("2. Click the 'Generate Summary' button.")