ErnestBeckham's picture
create app.py
90f5a24
raw
history blame contribute delete
No virus
848 Bytes
import streamlit as st
from transformers import pipeline
gen_kwargs = {"length_penalty": 0.8, "num_beams":8, "max_length": 128}
def main():
st.title("Text Summarizer App")
# Get user input
user_input = st.text_area("Enter text to summarize:")
# Button to trigger summarization
if st.button("Summarize"):
if user_input:
# Summarize the user input using the model
pipe = pipeline("summarization", model='ErnestBeckham/flan-t5-base-news-summarization', tokenizer='ErnestBeckham/flan-t5-base-news-summarization')
# Display the summarized output
st.subheader("Summary:")
st.write(pipe(user_input, **gen_kwargs)[0]["summary_text"])
else:
st.warning("Please enter text before summarizing.")
if __name__ == "__main__":
main()