awacke1 commited on
Commit
313ae67
·
verified ·
1 Parent(s): e54ce94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -299,14 +299,25 @@ with tab_download:
299
 
300
 
301
  mode = st.selectbox("Snapshot Mode", ["Single Page (High-Res)", "Two Pages (High-Res)", "All Pages (High-Res)"], key="download_mode") # 🎛️ Selectbox: Choose your snapshot resolution!
302
- if st.button("Snapshot Selected 📸"): # 📸 Button: Time to snap some PDF snapshots!
303
- selected_pdfs = [path for path in get_gallery_files() if path.endswith('.pdf') and st.session_state['asset_checkboxes'].get(path, False)] # 📄 Filter: Pick only the PDFs marked for snapshotting!
 
304
  if selected_pdfs:
305
  for pdf_path in selected_pdfs:
306
- mode_key = {"Single Page (High-Res)": "single", "Two Pages (High-Res)": "twopage", "All Pages (High-Res)": "allpages"}[mode]; snapshots = asyncio.run(process_pdf_snapshot(pdf_path, mode_key)) # 🔄 Processing: Generate snapshots per selected mode!
307
- for snapshot in snapshots: st.image(Image.open(snapshot), caption=snapshot, use_container_width=True); st.session_state['asset_checkboxes'][snapshot] = True # 🖼️ Display: Show each snapshot and mark it for potential SFT!
308
- update_gallery() # 🔄 Refresh gallery: Let the new snapshots shine!
309
- else: st.warning("No PDFs selected for snapshotting! Check some boxes in the sidebar.") # ⚠️ Warning: No PDFs chosen—select some boxes to make magic happen!
 
 
 
 
 
 
 
 
 
 
310
 
311
  # === Tab: Test OCR ===
312
  with tab_ocr:
 
299
 
300
 
301
  mode = st.selectbox("Snapshot Mode", ["Single Page (High-Res)", "Two Pages (High-Res)", "All Pages (High-Res)"], key="download_mode") # 🎛️ Selectbox: Choose your snapshot resolution!
302
+ if st.button("Snapshot Selected 📸"):
303
+ selected_pdfs = [path for path in get_gallery_files()
304
+ if path.endswith('.pdf') and st.session_state['asset_checkboxes'].get(path, False)]
305
  if selected_pdfs:
306
  for pdf_path in selected_pdfs:
307
+ if not os.path.exists(pdf_path):
308
+ st.warning(f"File not found: {pdf_path}. Skipping.")
309
+ continue
310
+ mode_key = {"Single Page (High-Res)": "single",
311
+ "Two Pages (High-Res)": "twopage",
312
+ "All Pages (High-Res)": "allpages"}[mode]
313
+ snapshots = asyncio.run(process_pdf_snapshot(pdf_path, mode_key))
314
+ for snapshot in snapshots:
315
+ st.image(Image.open(snapshot), caption=snapshot, use_container_width=True)
316
+ st.session_state['asset_checkboxes'][snapshot] = True
317
+ update_gallery()
318
+ else:
319
+ st.warning("No PDFs selected for snapshotting! Check some boxes in the sidebar.")
320
+
321
 
322
  # === Tab: Test OCR ===
323
  with tab_ocr: