Ayaan Sharif
commited on
Commit
Β·
b25c162
1
Parent(s):
bf1a42b
Fix duplicate processing from Examples
Browse files- Remove fn and outputs from Examples components
- Examples now only populate inputs, letting file_input.change handle processing
- This prevents double-processing: once from Examples fn, once from change event
- Reduces processing time and resource usage by 50%
app.py
CHANGED
|
@@ -687,18 +687,15 @@ with gr.Blocks(title="Document Layout Detection", theme=gr.themes.Soft()) as dem
|
|
| 687 |
Click on any example document to see instant results on different document types.
|
| 688 |
""")
|
| 689 |
|
| 690 |
-
# Add examples; clicking a row will
|
| 691 |
with gr.Row():
|
| 692 |
gr.Examples(
|
| 693 |
examples=[
|
| 694 |
["sample/Screenshot 2025-10-13 114010.png", "Fast", True, True, False, 0.05],
|
| 695 |
["sample/Screenshot 2025-10-13 114606.png", "Fast", True, True, False, 0.05],
|
| 696 |
-
["sample/Screenshot 2025-10-
|
| 697 |
],
|
| 698 |
inputs=[file_input, mode_dropdown, ocr_checkbox, tables_checkbox, run_sig_chk, sig_conf_slider],
|
| 699 |
-
outputs=[input_preview, visualization_output, summary_output, markdown_output, json_output],
|
| 700 |
-
fn=analyze_with_preview,
|
| 701 |
-
cache_examples=False,
|
| 702 |
label="π Example Documents",
|
| 703 |
examples_per_page=3
|
| 704 |
)
|
|
@@ -745,8 +742,6 @@ with gr.Blocks(title="Document Layout Detection", theme=gr.themes.Soft()) as dem
|
|
| 745 |
["sample_signature/X_081.jpeg", True, 0.03, 0.45, True]
|
| 746 |
],
|
| 747 |
inputs=[sig_file_input, try_scales, sig_only_conf, sig_only_iou, sig_only_aug],
|
| 748 |
-
outputs=[sig_input_preview, sig_only_image, sig_only_summary, sig_only_json],
|
| 749 |
-
fn=signature_only_with_preview,
|
| 750 |
label="βοΈ Signature Examples",
|
| 751 |
cache_examples=False
|
| 752 |
)
|
|
|
|
| 687 |
Click on any example document to see instant results on different document types.
|
| 688 |
""")
|
| 689 |
|
| 690 |
+
# Add examples; clicking a row will trigger file_input.change automatically
|
| 691 |
with gr.Row():
|
| 692 |
gr.Examples(
|
| 693 |
examples=[
|
| 694 |
["sample/Screenshot 2025-10-13 114010.png", "Fast", True, True, False, 0.05],
|
| 695 |
["sample/Screenshot 2025-10-13 114606.png", "Fast", True, True, False, 0.05],
|
| 696 |
+
["sample/Screenshot 2025-10-13 114615.png", "Fast", True, True, False, 0.05],
|
| 697 |
],
|
| 698 |
inputs=[file_input, mode_dropdown, ocr_checkbox, tables_checkbox, run_sig_chk, sig_conf_slider],
|
|
|
|
|
|
|
|
|
|
| 699 |
label="π Example Documents",
|
| 700 |
examples_per_page=3
|
| 701 |
)
|
|
|
|
| 742 |
["sample_signature/X_081.jpeg", True, 0.03, 0.45, True]
|
| 743 |
],
|
| 744 |
inputs=[sig_file_input, try_scales, sig_only_conf, sig_only_iou, sig_only_aug],
|
|
|
|
|
|
|
| 745 |
label="βοΈ Signature Examples",
|
| 746 |
cache_examples=False
|
| 747 |
)
|