Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 📸"):
|
| 303 |
-
selected_pdfs = [path for path in get_gallery_files()
|
|
|
|
| 304 |
if selected_pdfs:
|
| 305 |
for pdf_path in selected_pdfs:
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|