Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,19 @@ def get_formatted_text_for_annotation(output):
|
|
90 |
annotated_texts.append(text[next_index-1:len(text)-1])
|
91 |
|
92 |
return tuple(annotated_texts)
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
# Model initialization
|
95 |
pipeline_summarization = init_text_summarization_model()
|
96 |
pipeline_zsl, template = init_zsl_topic_classification()
|
@@ -116,6 +128,7 @@ if selected_menu == "Upload Document":
|
|
116 |
|
117 |
with open(file_path,"wb") as f:
|
118 |
f.write(uploaded_file.getbuffer())
|
|
|
119 |
|
120 |
elif selected_menu == "Extract Text":
|
121 |
with st.spinner("Extracting Text..."):
|
|
|
90 |
annotated_texts.append(text[next_index-1:len(text)-1])
|
91 |
|
92 |
return tuple(annotated_texts)
|
93 |
+
|
94 |
+
def displayPDF(file):
|
95 |
+
# Opening file from file path
|
96 |
+
with open(file, "rb") as f:
|
97 |
+
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
|
98 |
+
|
99 |
+
# Embedding PDF in HTML
|
100 |
+
pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}" width="700" height="1000" type="application/pdf"></iframe>'
|
101 |
+
|
102 |
+
# Displaying File
|
103 |
+
st.markdown(pdf_display, unsafe_allow_html=True)
|
104 |
+
|
105 |
+
|
106 |
# Model initialization
|
107 |
pipeline_summarization = init_text_summarization_model()
|
108 |
pipeline_zsl, template = init_zsl_topic_classification()
|
|
|
128 |
|
129 |
with open(file_path,"wb") as f:
|
130 |
f.write(uploaded_file.getbuffer())
|
131 |
+
displayPDF(file_path)
|
132 |
|
133 |
elif selected_menu == "Extract Text":
|
134 |
with st.spinner("Extracting Text..."):
|