text_sum1 / app.py
sharath6900's picture
Create app.py
bf7b3cb verified
raw
history blame
783 Bytes
import streamlit as st
from transformers import pipeline
# Load the summarization pipeline
summarizer = pipeline("summarization")
def summarize_text(text):
"""Summarize the input text using Hugging Face's pipeline."""
summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
return summary[0]['summary_text']
# Streamlit UI
st.title("Text Summarization with Hugging Face")
st.write("Enter the text you want to summarize:")
# Text input from the user
user_input = st.text_area("Input Text", height=200)
if st.button("Summarize"):
if user_input:
# Generate summary
summary = summarize_text(user_input)
st.subheader("Summary:")
st.write(summary)
else:
st.error("Please enter some text to summarize.")