Commit
·
58d8dc0
1
Parent(s):
b5f90b5
Added app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
st.title("Text Summarization App |PEGASUS-Large|) ")
|
6 |
+
|
7 |
+
# Create a text input widget
|
8 |
+
text_input = st.text_area(label="Input Text", height=200)
|
9 |
+
|
10 |
+
# Define a function to generate the summary
|
11 |
+
def generate_summary(text):
|
12 |
+
summarizer = pipeline("summarization", model="sabre-code/pegasus-large-cnn-dailymail")
|
13 |
+
generated_summary = summarizer(text)
|
14 |
+
|
15 |
+
|
16 |
+
# Return the generated summary
|
17 |
+
return generated_summary
|
18 |
+
|
19 |
+
# Add a button to trigger the generation of the summary
|
20 |
+
generate_button = st.button(label="Generate Summary")
|
21 |
+
if generate_button:
|
22 |
+
# Call the generate_summary function when the button is clicked
|
23 |
+
generated_summary = generate_summary(text_input.value)
|
24 |
+
st.success("Summary Generated!")
|
25 |
+
else:
|
26 |
+
st.warning("Please enter some text in the input field above.")
|
27 |
+
|
28 |
+
# Display the generated summary
|
29 |
+
st.markdown("# Summary")
|
30 |
+
st.code(generated_summary)
|