Spaces:
Sleeping
Sleeping
File size: 1,173 Bytes
6ce28c5 e2199a7 6ce28c5 e2199a7 b748939 6ce28c5 e2199a7 6ce28c5 e2199a7 6ce28c5 e2199a7 6ce28c5 e2199a7 6ce28c5 e2199a7 6ce28c5 e2199a7 6ce28c5 e876df0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import streamlit as st
from transformers import pipeline
# Load the summarization model from Hugging Face
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", revision="a4f8f3e")
# Streamlit app
def main():
# Set the title and description of the app
st.title("Text Summarizer App")
st.write(
"Enter a piece of text, select the length of the summary, and get a concise summary!"
)
# Input text box for user input
input_text = st.text_area("Enter your text here:")
# Length selector for summary
summary_length = st.slider("Select summary length:", min_value=50, max_value=500, value=150, step=50)
# Check if the user has entered any text
if st.button("Generate Summary"):
if not input_text:
st.warning("Please enter some text.")
else:
# Generate summary using the Hugging Face summarization model
summary = summarizer(input_text, max_length=summary_length, min_length=50, length_penalty=2.0, num_beams=4)
st.subheader("Summary:")
st.write(summary[0]["summary_text"])
# Run the app
if __name__ == "__main__":
main()
|