Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,25 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, pipeline
|
3 |
+
|
4 |
+
st.title("Text Summarization App")
|
5 |
+
|
6 |
+
# Initialize the summarizer
|
7 |
+
summarizer = pipeline("summarization", model="pszemraj/led-large-book-summary")
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("pszemraj/led-large-book-summary")
|
9 |
+
|
10 |
+
# Input text area
|
11 |
+
article = st.text_area("Enter Text to Summarize:")
|
12 |
+
|
13 |
+
# Summarization button
|
14 |
+
if st.button("Summarize"):
|
15 |
+
if article:
|
16 |
+
# Perform summarization
|
17 |
+
data = summarizer(article, max_length=200, min_length=180, do_sample=False)
|
18 |
+
summary = data[0]["summary_text"]
|
19 |
+
|
20 |
+
# Display the summary
|
21 |
+
st.subheader("Summary:")
|
22 |
+
st.write(summary)
|
23 |
+
else:
|
24 |
+
st.warning("Please enter some text to summarize.")
|
25 |
+
|