Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the BART model for text summarization from Hugging Face
|
5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
6 |
+
|
7 |
+
# Streamlit app layout
|
8 |
+
st.title("Text Summarization Tool")
|
9 |
+
st.write("Automatically summarizes long articles or documents into concise summaries using the BART model.")
|
10 |
+
|
11 |
+
# Input field for the user to enter or paste the text
|
12 |
+
input_text = st.text_area("Enter the text you want to summarize:", height=300)
|
13 |
+
|
14 |
+
# Check if there is input text
|
15 |
+
if input_text:
|
16 |
+
# Display the original text
|
17 |
+
st.subheader("Original Text:")
|
18 |
+
st.write(input_text)
|
19 |
+
|
20 |
+
# Generate the summary using the pre-trained BART model
|
21 |
+
summary = summarizer(input_text, max_length=200, min_length=50, do_sample=False)
|
22 |
+
|
23 |
+
# Display the summarized text
|
24 |
+
st.subheader("Summary:")
|
25 |
+
st.write(summary[0]['summary_text'])
|
26 |
+
|
27 |
+
# Option to clear the input
|
28 |
+
if st.button("Clear Text"):
|
29 |
+
st.text_area("Enter the text you want to summarize:", value="")
|