Spaces:
Runtime error
Runtime error
Change to raw output
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import pdfkit
|
| 3 |
from PyPDF2 import PdfReader
|
| 4 |
|
| 5 |
from transformers import pipeline
|
|
@@ -29,9 +28,9 @@ if st.button('Summarize text'):
|
|
| 29 |
st.markdown(f'''
|
| 30 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
| 31 |
<h4>Results</h4>
|
| 32 |
-
<
|
| 33 |
{output}
|
| 34 |
-
</
|
| 35 |
</div>
|
| 36 |
''', unsafe_allow_html=True)
|
| 37 |
st.success('Done')
|
|
@@ -61,15 +60,18 @@ try:
|
|
| 61 |
for page in pages:
|
| 62 |
page_text = page.extract_text()
|
| 63 |
page_text_stack.append(page_text)
|
| 64 |
-
|
| 65 |
-
# pages_stack = []
|
| 66 |
-
|
| 67 |
-
# for text_stack in page_text_stack:
|
| 68 |
-
# pages_stack.append(text_stack)
|
| 69 |
-
|
| 70 |
return page_text_stack
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
except: # Handle blank file error
|
|
@@ -77,11 +79,7 @@ except: # Handle blank file error
|
|
| 77 |
|
| 78 |
# Prepare output
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
pdf_output = summarize_text(pdf_input)
|
| 83 |
-
|
| 84 |
-
summary_pdf = pdfkit.from_string(pdf_output, 'Summary.pdf')
|
| 85 |
|
| 86 |
|
| 87 |
|
|
@@ -90,7 +88,7 @@ if st.button('Summarize pdf page'):
|
|
| 90 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
| 91 |
<h4>Download the summary here </h4>
|
| 92 |
<p>
|
| 93 |
-
{
|
| 94 |
</p>
|
| 95 |
</div>
|
| 96 |
''', unsafe_allow_html=True)
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from PyPDF2 import PdfReader
|
| 3 |
|
| 4 |
from transformers import pipeline
|
|
|
|
| 28 |
st.markdown(f'''
|
| 29 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
| 30 |
<h4>Results</h4>
|
| 31 |
+
<div>
|
| 32 |
{output}
|
| 33 |
+
</div>
|
| 34 |
</div>
|
| 35 |
''', unsafe_allow_html=True)
|
| 36 |
st.success('Done')
|
|
|
|
| 60 |
for page in pages:
|
| 61 |
page_text = page.extract_text()
|
| 62 |
page_text_stack.append(page_text)
|
| 63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
return page_text_stack
|
| 65 |
+
|
| 66 |
+
pdf_input = extract_text(uploaded_pdf)
|
| 67 |
+
|
| 68 |
+
pdf_output = []
|
| 69 |
|
| 70 |
+
for stack in pdf_input:
|
| 71 |
+
summarize_text(stack)
|
| 72 |
+
pdf_output.append(stack)
|
| 73 |
+
|
| 74 |
+
pdf_summary = '\n'.join(pdf_output)
|
| 75 |
|
| 76 |
|
| 77 |
except: # Handle blank file error
|
|
|
|
| 79 |
|
| 80 |
# Prepare output
|
| 81 |
|
| 82 |
+
# summary_pdf = pdfkit.from_string(pdf_output, 'Summary.pdf')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
|
|
|
|
| 88 |
<div style="background-color: black; color: white; font-weight: bold; padding: 1rem; border-radius: 10px;">
|
| 89 |
<h4>Download the summary here </h4>
|
| 90 |
<p>
|
| 91 |
+
{pdf_summary}
|
| 92 |
</p>
|
| 93 |
</div>
|
| 94 |
''', unsafe_allow_html=True)
|