Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,23 @@
|
|
1 |
-
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the summarization pipeline from Hugging Face
|
5 |
+
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
6 |
|
7 |
+
# Streamlit interface
|
8 |
+
st.title("Text Summarization App")
|
9 |
+
|
10 |
+
# Text input
|
11 |
+
input_text = st.text_area("Enter the text to summarize:", height=200)
|
12 |
+
|
13 |
+
if st.button("Summarize"):
|
14 |
+
if input_text:
|
15 |
+
# Summarize the text
|
16 |
+
summary = summarizer(input_text, max_length=50, min_length=25, do_sample=False)
|
17 |
+
summarized_text = summary[0]['summary_text']
|
18 |
+
|
19 |
+
# Display the summary
|
20 |
+
st.subheader("Summary")
|
21 |
+
st.write(summarized_text)
|
22 |
+
else:
|
23 |
+
st.error("Please enter some text to summarize.")
|