Ziptoze commited on
Commit
d9df290
·
verified ·
1 Parent(s): 5613799

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -243,8 +243,8 @@ 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 (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]
@@ -361,9 +361,7 @@ with gr.Blocks(title="Ultra OCR", theme=theme, css=custom_css) as demo:
361
  label="📄 Document Source",
362
  height=500,
363
  sources=['upload', 'clipboard'],
364
- format="png",
365
- show_label=True,
366
- image_mode="RGB"
367
  )
368
  run_btn = gr.Button("⚡ Start Transcription", variant="primary", size="lg")
369
 
@@ -398,9 +396,8 @@ with gr.Blocks(title="Ultra OCR", theme=theme, css=custom_css) as demo:
398
  )
399
 
400
  if __name__ == "__main__":
401
- # Fix for spaces visual/SSR errors: Disable SSR (Server Side Rendering)
402
- # This fixes "weird UI" glitches and image compatibility issues on modern Gradio versions
403
  demo.launch(
404
- allowed_paths=[os.path.dirname(os.path.abspath(__file__))],
405
- ssr_mode=False
406
  )
 
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 ABSOLUTE paths (Matches app.py which works)
247
+ example_images = [[os.path.join(data_dir, 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]
 
361
  label="📄 Document Source",
362
  height=500,
363
  sources=['upload', 'clipboard'],
364
+ format="png"
 
 
365
  )
366
  run_btn = gr.Button("⚡ Start Transcription", variant="primary", size="lg")
367
 
 
396
  )
397
 
398
  if __name__ == "__main__":
399
+ # Removed ssr_mode=False to fix gallery previews.
400
+ # Using absolute paths with allowed_paths matches the working app.py config.
401
  demo.launch(
402
+ allowed_paths=[os.path.dirname(os.path.abspath(__file__))]
 
403
  )