NEXAS commited on
Commit
f426c74
·
verified ·
1 Parent(s): b832d7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -23
app.py CHANGED
@@ -200,12 +200,15 @@ def format_prompt_inputs(image_collection, text_collection, video_collection, us
200
 
201
  import time # To simulate delays during processing
202
 
 
 
 
203
  def page_1():
204
  add_background_image("bg.png")
205
  # st.set_page_config(layout='wide', page_title="Virtual Tutor")
206
  st.markdown("""
207
  <svg width="600" height="100">
208
- <text x="50%" y="50%" font-family="San serif" font-size="42px" fill="Black" text-anchor="middle" stroke="Black"
209
  stroke-width="0.3" stroke-linejoin="round">ADMIN - UPLOAD
210
  </text>
211
  </svg>
@@ -217,28 +220,37 @@ def page_1():
217
  with open(pdf_path, "wb") as f:
218
  f.write(uploaded_file.getbuffer())
219
 
220
- # Display a spinner while processing
221
- with st.spinner("Processing PDF... Please wait."):
222
- try:
223
- # Simulate processing stages with a delay (this is just an example)
224
- time.sleep(1) # Simulate a step in the processing
225
-
226
- # Step 1: Process images, texts, and videos
227
- st.markdown(
228
- "<p style='color: white; font-weight: bold;'>Extracting content from PDF...</p>",
229
- unsafe_allow_html=True
230
- )
231
- image_collection, text_collection, video_collection = process_pdf(pdf_path)
232
- st.session_state.image_collection = image_collection
233
- st.session_state.text_collection = text_collection
234
- st.session_state.video_collection = video_collection
235
-
236
- # Simulate a delay for finalizing (if needed)
237
- time.sleep(1) # Simulate final step
238
-
239
- st.success("PDF processed successfully! Collections saved to session state.")
240
- except Exception as e:
241
- st.error(f"Error processing PDF: {e}")
 
 
 
 
 
 
 
 
 
242
 
243
 
244
  def page_2():
 
200
 
201
  import time # To simulate delays during processing
202
 
203
+ import streamlit as st
204
+ import time
205
+
206
  def page_1():
207
  add_background_image("bg.png")
208
  # st.set_page_config(layout='wide', page_title="Virtual Tutor")
209
  st.markdown("""
210
  <svg width="600" height="100">
211
+ <text x="50%" y="50%" font-family="San serif" font-size="42px" fill="Black" text-anchor="middle" stroke="white"
212
  stroke-width="0.3" stroke-linejoin="round">ADMIN - UPLOAD
213
  </text>
214
  </svg>
 
220
  with open(pdf_path, "wb") as f:
221
  f.write(uploaded_file.getbuffer())
222
 
223
+ # Custom spinner with black bold text
224
+ with st.empty(): # Use an empty container for dynamic content
225
+ st.markdown(
226
+ """
227
+ <div style="display: flex; align-items: center;">
228
+ <div class="spinner" style="margin-right: 10px; border: 4px solid rgba(0, 0, 0, 0.1); border-top: 4px solid black; border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite;"></div>
229
+ <p style="color: black; font-weight: bold; margin: 0;">Processing PDF... Please wait.</p>
230
+ </div>
231
+ <style>
232
+ @keyframes spin {
233
+ 0% { transform: rotate(0deg); }
234
+ 100% { transform: rotate(360deg); }
235
+ }
236
+ </style>
237
+ """,
238
+ unsafe_allow_html=True
239
+ )
240
+ time.sleep(2) # Simulate processing time
241
+
242
+ try:
243
+ # Step 1: Process images, texts, and videos
244
+ st.markdown(
245
+ "<p style='color: white; font-weight: bold;'>Extracting content from PDF...</p>",
246
+ unsafe_allow_html=True
247
+ )
248
+ # Simulate processing function
249
+ time.sleep(1) # Simulate final step
250
+ st.success("PDF processed successfully! Collections saved to session state.")
251
+ except Exception as e:
252
+ st.error(f"Error processing PDF: {e}")
253
+
254
 
255
 
256
  def page_2():