Summarization / app.py
hardik90's picture
Create app.py
14d4d32 verified
raw
history blame contribute delete
764 Bytes
import streamlit as st
from transformers import pipeline
# Load summarization model from Hugging Face
summarizer = pipeline("summarization", model="google/pegasus-xsum")
# Streamlit UI
def main():
st.title("Text Summarization App")
# User input
user_input = st.text_area("Enter your text for summarization:")
if st.button("Generate Summary"):
if user_input:
# Perform summarization
summary = summarizer(user_input, max_length=150, min_length=50, length_penalty=2.0, num_beams=4)[0]['summary_text']
# Display result
st.write("Summary:")
st.write(summary)
else:
st.warning("Please enter some text for summarization.")
if __name__ == "__main__":
main()