Spaces:
Runtime error
Runtime error
Update functions
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
|
|
|
4 |
from transformers import pipeline
|
5 |
|
6 |
summarizer = pipeline(task="summarization")
|
@@ -69,13 +70,10 @@ try:
|
|
69 |
except: # Handle blank file error
|
70 |
st.error('Please select a valid file')
|
71 |
|
72 |
-
# Prepare output
|
73 |
-
|
74 |
-
|
75 |
-
# summary_pdf = pdfkit.from_string(pdf_output, 'Summary.pdf')
|
76 |
-
|
77 |
|
|
|
78 |
|
|
|
79 |
if st.button('Summarize pdf content'):
|
80 |
with st.spinner('Extracting text from PDF...'):
|
81 |
pdf_input = extract_text(uploaded_pdf)
|
@@ -94,17 +92,26 @@ if st.button('Summarize pdf content'):
|
|
94 |
|
95 |
st.markdown(f'''
|
96 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
97 |
-
<h4>Summary</h4>
|
98 |
<p>{pdf_summary}</p>
|
99 |
</div>
|
100 |
''', unsafe_allow_html=True)
|
101 |
-
|
102 |
-
|
103 |
st.success('PDF page summarized :)', icon="✅")
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
|
|
|
|
|
|
105 |
|
106 |
st.write('')
|
107 |
-
st.write(''
|
108 |
|
109 |
|
110 |
st.markdown("<hr style='border: 1px dashed #ddd; margin: 2rem;'>", unsafe_allow_html=True) #Horizontal line
|
@@ -121,5 +128,3 @@ st.markdown("""
|
|
121 |
</div>
|
122 |
""",
|
123 |
unsafe_allow_html=True)
|
124 |
-
|
125 |
-
# Peace Out :)
|
|
|
1 |
import streamlit as st
|
2 |
+
import pdfkit
|
3 |
|
4 |
+
from PyPDF2 import PdfReader
|
5 |
from transformers import pipeline
|
6 |
|
7 |
summarizer = pipeline(task="summarization")
|
|
|
70 |
except: # Handle blank file error
|
71 |
st.error('Please select a valid file')
|
72 |
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
|
75 |
|
76 |
+
# Processs to trigger summary
|
77 |
if st.button('Summarize pdf content'):
|
78 |
with st.spinner('Extracting text from PDF...'):
|
79 |
pdf_input = extract_text(uploaded_pdf)
|
|
|
92 |
|
93 |
st.markdown(f'''
|
94 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
95 |
+
<h4>Summary </h4>
|
96 |
<p>{pdf_summary}</p>
|
97 |
</div>
|
98 |
''', unsafe_allow_html=True)
|
99 |
+
|
100 |
+
generate_download_button = st.button('Generate')
|
101 |
st.success('PDF page summarized :)', icon="✅")
|
102 |
+
|
103 |
+
|
104 |
+
# Summary text to PDF function
|
105 |
+
def summary_download():
|
106 |
+
# summary_pdf = pdfkit.from_string(pdf_summary, 'Summary.pdf')
|
107 |
+
st.download_button(label='Download summary PDF', data=pdf_summary, file_name='summary.pdf', mime='application/pdf')
|
108 |
|
109 |
+
if generate_download_button:
|
110 |
+
summary_download()
|
111 |
+
|
112 |
|
113 |
st.write('')
|
114 |
+
st.write('')
|
115 |
|
116 |
|
117 |
st.markdown("<hr style='border: 1px dashed #ddd; margin: 2rem;'>", unsafe_allow_html=True) #Horizontal line
|
|
|
128 |
</div>
|
129 |
""",
|
130 |
unsafe_allow_html=True)
|
|
|
|