Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
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
|
| 247 |
-
example_images = [[os.path.join(
|
| 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 |
-
#
|
| 402 |
-
#
|
| 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 |
)
|