Spaces:
Runtime error
Runtime error
viboognesh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -92,10 +92,11 @@ def main():
|
|
92 |
# Get filenames from uploaded files
|
93 |
filename1 = st.session_state.file1.name
|
94 |
filename2 = st.session_state.file2.name
|
95 |
-
|
96 |
-
|
97 |
-
st.session_state.display_data
|
98 |
-
|
|
|
99 |
|
100 |
try:
|
101 |
extracted_text1 = st.session_state.extracted_texts["extracted_text_1"]
|
@@ -106,7 +107,7 @@ def main():
|
|
106 |
with col2.expander(filename2):
|
107 |
st.write("\n\n".join("\n\n------------------------\n\n".join(extracted_text2).splitlines()))
|
108 |
|
109 |
-
st.success(f"
|
110 |
except Exception as e:
|
111 |
st.error(f"Error saving files: {str(e)}")
|
112 |
|
|
|
92 |
# Get filenames from uploaded files
|
93 |
filename1 = st.session_state.file1.name
|
94 |
filename2 = st.session_state.file2.name
|
95 |
+
|
96 |
+
with st.spinner("Extracting text from PDFs"):
|
97 |
+
if st.session_state.display_data["file1"] != st.session_state.file1 or st.session_state.display_data["file2"] != st.session_state.file2:
|
98 |
+
st.session_state.display_data = {"file1": st.session_state.file1, "file2": st.session_state.file2, "i": 0}
|
99 |
+
st.session_state.extracted_texts = {"file1": st.session_state.display_data["file1"], "file2": st.session_state.display_data["file2"], "extracted_text_1": extract_text_with_pypdf(st.session_state.file1), "extracted_text_2": extract_text_with_pypdf(st.session_state.file2)}
|
100 |
|
101 |
try:
|
102 |
extracted_text1 = st.session_state.extracted_texts["extracted_text_1"]
|
|
|
107 |
with col2.expander(filename2):
|
108 |
st.write("\n\n".join("\n\n------------------------\n\n".join(extracted_text2).splitlines()))
|
109 |
|
110 |
+
st.success(f"PDF text extraction complete")
|
111 |
except Exception as e:
|
112 |
st.error(f"Error saving files: {str(e)}")
|
113 |
|