Update app.py
Browse files
app.py
CHANGED
@@ -210,33 +210,31 @@ def page_1():
|
|
210 |
</text>
|
211 |
</svg>
|
212 |
""", unsafe_allow_html=True)
|
213 |
-
|
214 |
uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])
|
215 |
if uploaded_file:
|
216 |
pdf_path = f"/tmp/{uploaded_file.name}"
|
217 |
with open(pdf_path, "wb") as f:
|
218 |
f.write(uploaded_file.getbuffer())
|
219 |
|
220 |
-
#
|
221 |
with st.spinner("Processing PDF... Please wait."):
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
"
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
st.session_state.text_collection = text_collection
|
233 |
-
st.session_state.video_collection = video_collection
|
234 |
-
# Simulate processing function
|
235 |
-
time.sleep(1) # Simulate final step
|
236 |
-
st.success("PDF processed successfully! Collections saved to session state.")
|
237 |
-
except Exception as e:
|
238 |
-
st.error(f"Error processing PDF: {e}")
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
|
241 |
def page_2():
|
242 |
add_background_image("bg2.jpg")
|
|
|
210 |
</text>
|
211 |
</svg>
|
212 |
""", unsafe_allow_html=True)
|
|
|
213 |
uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])
|
214 |
if uploaded_file:
|
215 |
pdf_path = f"/tmp/{uploaded_file.name}"
|
216 |
with open(pdf_path, "wb") as f:
|
217 |
f.write(uploaded_file.getbuffer())
|
218 |
|
219 |
+
# Display a spinner while processing
|
220 |
with st.spinner("Processing PDF... Please wait."):
|
221 |
+
try:
|
222 |
+
# Simulate processing stages with a delay (this is just an example)
|
223 |
+
time.sleep(1) # Simulate a step in the processing
|
224 |
+
|
225 |
+
# Step 1: Process images, texts, and videos
|
226 |
+
st.text("Extracting content from PDF...")
|
227 |
+
image_collection, text_collection, video_collection = process_pdf(pdf_path)
|
228 |
+
st.session_state.image_collection = image_collection
|
229 |
+
st.session_state.text_collection = text_collection
|
230 |
+
st.session_state.video_collection = video_collection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
|
232 |
+
# Simulate a delay for finalizing (if needed)
|
233 |
+
time.sleep(1) # Simulate final step
|
234 |
+
|
235 |
+
st.success("PDF processed successfully! Collections saved to session state.")
|
236 |
+
except Exception as e:
|
237 |
+
st.error(f"Error processing PDF: {e}")
|
238 |
|
239 |
def page_2():
|
240 |
add_background_image("bg2.jpg")
|