From c25e71a4c7d706c71676fc31a05a8ac4fb737932 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 19 Jan 2026 14:17:37 +0100 Subject: [PATCH] Update tab_gallery_sorter.py --- tab_gallery_sorter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tab_gallery_sorter.py b/tab_gallery_sorter.py index a582f43..ebd0761 100644 --- a/tab_gallery_sorter.py +++ b/tab_gallery_sorter.py @@ -121,6 +121,10 @@ def render_gallery_grid(current_batch, quality, grid_cols): selected_cat = st.session_state.get("t5_active_cat", "Default") tagging_disabled = selected_cat.startswith("---") + # --- NEW: LOAD ALL IMAGES IN PARALLEL --- + # This runs multithreaded and is much faster than the old loop + batch_cache = SorterEngine.load_batch_parallel(current_batch, quality) + cols = st.columns(grid_cols) for idx, img_path in enumerate(current_batch): unique_key = f"frag_{os.path.basename(img_path)}" @@ -138,8 +142,10 @@ def render_gallery_grid(current_batch, quality, grid_cols): elif is_processed: st.info(f"✅ {history[img_path]['action']} -> {history[img_path]['cat']}") - img_data = SorterEngine.compress_for_web(img_path, quality) - if img_data: st.image(img_data, use_container_width=True) + # --- CHANGED: USE PRE-LOADED DATA --- + img_data = batch_cache.get(img_path) + if img_data: + st.image(img_data, use_container_width=True) if not is_staged: st.button("Tag", key=f"tag_{unique_key}", disabled=tagging_disabled, use_container_width=True,