Hypernova823 commited on
Commit
cbdfce9
Β·
verified Β·
1 Parent(s): 4f4793f

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -5
src/streamlit_app.py CHANGED
@@ -153,13 +153,14 @@ div[data-testid="stFileUploader"] * {
153
  # ═══════════════════════════════════════════════════════════════
154
  # MODELS & OCR LOGIC
155
  # ═══════════════════════════════════════════════════════════════
156
-
 
157
  def load_vision_engine():
158
  import logging
159
  logging.getLogger("easyocr").setLevel(logging.ERROR)
160
  return easyocr.Reader(['en'], gpu=torch.cuda.is_available())
161
 
162
-
163
  def load_trocr_model(model_path):
164
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
165
 
@@ -262,9 +263,10 @@ def main():
262
  if run_scan_trigger:
263
  start = time.time()
264
 
265
- # This triggers the @st.cache_resource loaders
266
- proc, model, device = load_trocr_model(m_map[model_choice])
267
- crops = extract_lines(st.session_state.image_data, reader)
 
268
 
269
  decoded, scores = [], []
270
  total_crops = len(crops)
 
153
  # ═══════════════════════════════════════════════════════════════
154
  # MODELS & OCR LOGIC
155
  # ═══════════════════════════════════════════════════════════════
156
+ # THE KILL-SWITCH: show_spinner=False completely deletes the un-styleable white cache boxes
157
+ @st.cache_resource(show_spinner=False)
158
  def load_vision_engine():
159
  import logging
160
  logging.getLogger("easyocr").setLevel(logging.ERROR)
161
  return easyocr.Reader(['en'], gpu=torch.cuda.is_available())
162
 
163
+ @st.cache_resource(show_spinner=False)
164
  def load_trocr_model(model_path):
165
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
166
 
 
263
  if run_scan_trigger:
264
  start = time.time()
265
 
266
+ # The fully-styled, dark-mode spinner handles the wait time so the app doesn't freeze or refresh weirdly
267
+ with st.spinner("Allocating Neural Resources & Loading Weights..."):
268
+ proc, model, device = load_trocr_model(m_map[model_choice])
269
+ crops = extract_lines(st.session_state.image_data, reader)
270
 
271
  decoded, scores = [], []
272
  total_crops = len(crops)