Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +32 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
from summarizer.bert import Summarizer
|
| 4 |
+
|
| 5 |
+
# Summarization function using BERT-based summarizer
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def summarize_text(text, num_sentences=5):
|
| 9 |
+
model = Summarizer()
|
| 10 |
+
summarized_text = model(text, num_sentences=num_sentences)
|
| 11 |
+
return summarized_text
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# Streamlit app layout
|
| 15 |
+
st.title("Content Summarizer")
|
| 16 |
+
|
| 17 |
+
# Textbox for content to be summarized
|
| 18 |
+
user_input_text = st.text_area("Enter the content you want to summarize:")
|
| 19 |
+
|
| 20 |
+
# Slider to select the number of sentences in the summary
|
| 21 |
+
num_sentences = st.slider("Number of summary sentences:", min_value=1, max_value=10)
|
| 22 |
+
|
| 23 |
+
# Button to trigger summarization
|
| 24 |
+
if st.button('Summarize'):
|
| 25 |
+
# Check if there is text input
|
| 26 |
+
if user_input_text:
|
| 27 |
+
# Use num_sentences as the max_length parameter
|
| 28 |
+
summarized_content = summarize_text(user_input_text, num_sentences)
|
| 29 |
+
st.subheader("Summary")
|
| 30 |
+
st.write(summarized_content)
|
| 31 |
+
else:
|
| 32 |
+
st.warning("Please enter some content to summarize.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bert-extractive-summarizer==0.10.1
|
| 2 |
+
torch==2.1.1
|
| 3 |
+
streamlit==1.29.0
|
| 4 |
+
|
| 5 |
+
|