Ziptoze commited on
Commit
000d907
·
verified ·
1 Parent(s): ed72c4e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -243,13 +243,11 @@ if os.path.exists(data_dir):
243
  found_files = [f for f in os.listdir(data_dir) if os.path.splitext(f)[1].lower() in valid_exts]
244
  print(f"DEBUG: Found {len(found_files)} images in {data_dir}")
245
 
246
- # Use RELATIVE paths (data/file.jpg) to help Gradio's frontend URL resolution
247
- # This often fixes issues where absolute paths (/app/data/...) fail in the browser
248
  example_images = [[os.path.join("data", f)] for f in found_files]
249
 
250
- # Limit to 5 examples
251
  example_images = example_images[:5]
252
- print(f"DEBUG: Example paths generated: {example_images}")
253
  else:
254
  print(f"DEBUG: Data directory not found at {data_dir}")
255
 
@@ -387,8 +385,7 @@ with gr.Blocks(title="Ultra OCR", theme=theme, css=custom_css) as demo:
387
  )
388
 
389
  if __name__ == "__main__":
390
- # Removed ssr_mode=False to match app.py behavior (which worked historically)
391
- # Using relative path "." for allowed_paths to correspond with relative example paths
392
  demo.launch(
393
- allowed_paths=["."],
394
  )
 
243
  found_files = [f for f in os.listdir(data_dir) if os.path.splitext(f)[1].lower() in valid_exts]
244
  print(f"DEBUG: Found {len(found_files)} images in {data_dir}")
245
 
246
+ # Use RELATIVE paths (e.g. "data/image.jpg") which works best with Gradio's web server
 
247
  example_images = [[os.path.join("data", f)] for f in found_files]
248
 
249
+ # Limit to 5 examples to prevent UI clutter if many files exist
250
  example_images = example_images[:5]
 
251
  else:
252
  print(f"DEBUG: Data directory not found at {data_dir}")
253
 
 
385
  )
386
 
387
  if __name__ == "__main__":
388
+ # Removed ssr_mode=False as it breaks some interactions on Spaces
 
389
  demo.launch(
390
+ allowed_paths=[os.path.dirname(os.path.abspath(__file__))]
391
  )