Commit
·
28f17d5
1
Parent(s):
5f63988
refactor app.py
Browse files
app.py
CHANGED
|
@@ -801,9 +801,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 801 |
scale=0,
|
| 802 |
elem_classes=["tight-spacing"],
|
| 803 |
)
|
| 804 |
-
with gr.Column(
|
| 805 |
-
visible=False
|
| 806 |
-
) as Module_Options:
|
| 807 |
use_chart_recognition_md = gr.Markdown(
|
| 808 |
"### Using the chart parsing module",
|
| 809 |
elem_id="use_chart_recognition_md",
|
|
@@ -859,9 +857,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 859 |
show_label=False,
|
| 860 |
elem_id="use_textline_orientation_rd",
|
| 861 |
)
|
| 862 |
-
with gr.Column(
|
| 863 |
-
visible=True
|
| 864 |
-
) as Subpipeline_Options:
|
| 865 |
use_seal_recognition_md = gr.Markdown(
|
| 866 |
"### Using the seal text recognition subpipeline",
|
| 867 |
elem_id="use_seal_recognition_md",
|
|
@@ -895,9 +891,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 895 |
show_label=False,
|
| 896 |
elem_id="use_table_recognition_rd",
|
| 897 |
)
|
| 898 |
-
with gr.Column(
|
| 899 |
-
visible=False
|
| 900 |
-
) as Layout_region_detection_Options:
|
| 901 |
layout_threshold_md = gr.Markdown(
|
| 902 |
"### Score threshold of layout region detection model",
|
| 903 |
elem_id="layout_threshold_md",
|
|
@@ -935,9 +929,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 935 |
show_label=False,
|
| 936 |
elem_id="layout_unclip_ratio_nb",
|
| 937 |
)
|
| 938 |
-
with gr.Column(
|
| 939 |
-
visible=False
|
| 940 |
-
) as Text_detection_Options:
|
| 941 |
text_det_limit_type_md = gr.Markdown(
|
| 942 |
"### Image side length restriction type for text detection",
|
| 943 |
elem_id="text_det_limit_type_md",
|
|
@@ -1016,9 +1008,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 1016 |
elem_id="text_rec_score_thresh_nb",
|
| 1017 |
)
|
| 1018 |
|
| 1019 |
-
with gr.Column(
|
| 1020 |
-
visible=False
|
| 1021 |
-
) as Seal_text_recognition_Options:
|
| 1022 |
seal_det_limit_type_md = gr.Markdown(
|
| 1023 |
"### Image side length restriction type for seal text detection",
|
| 1024 |
elem_id="seal_det_limit_type_md",
|
|
@@ -1095,9 +1085,7 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 1095 |
show_label=False,
|
| 1096 |
elem_id="seal_rec_score_thresh_nb",
|
| 1097 |
)
|
| 1098 |
-
with gr.Column(
|
| 1099 |
-
visible=False
|
| 1100 |
-
) as Table_recognition_Options:
|
| 1101 |
use_ocr_results_with_table_cells_md = gr.Markdown(
|
| 1102 |
"### Cell OCR mode",
|
| 1103 |
elem_id="use_ocr_results_with_table_cells_md",
|
|
@@ -1362,11 +1350,11 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 1362 |
)
|
| 1363 |
)
|
| 1364 |
download_all_btn = gr.Button(
|
| 1365 |
-
|
| 1366 |
-
|
| 1367 |
-
|
| 1368 |
-
|
| 1369 |
-
|
| 1370 |
# # Navigation bar
|
| 1371 |
with gr.Column(elem_classes=["nav-bar"]):
|
| 1372 |
gr.HTML(
|
|
@@ -1404,7 +1392,14 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 1404 |
""",
|
| 1405 |
)
|
| 1406 |
process_btn.click(
|
| 1407 |
-
toggle_spinner,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1408 |
).then(
|
| 1409 |
process_file,
|
| 1410 |
inputs=[
|
|
@@ -1452,7 +1447,9 @@ with gr.Blocks(css=CSS, title="Document Analysis System", theme=paddle_theme) as
|
|
| 1452 |
+ output_json_list
|
| 1453 |
+ markdown_display_list
|
| 1454 |
+ gallery_list,
|
| 1455 |
-
).
|
|
|
|
|
|
|
| 1456 |
|
| 1457 |
gallery_markdown.select(
|
| 1458 |
update_markdown,
|
|
|
|
| 801 |
scale=0,
|
| 802 |
elem_classes=["tight-spacing"],
|
| 803 |
)
|
| 804 |
+
with gr.Column(visible=False) as Module_Options:
|
|
|
|
|
|
|
| 805 |
use_chart_recognition_md = gr.Markdown(
|
| 806 |
"### Using the chart parsing module",
|
| 807 |
elem_id="use_chart_recognition_md",
|
|
|
|
| 857 |
show_label=False,
|
| 858 |
elem_id="use_textline_orientation_rd",
|
| 859 |
)
|
| 860 |
+
with gr.Column(visible=True) as Subpipeline_Options:
|
|
|
|
|
|
|
| 861 |
use_seal_recognition_md = gr.Markdown(
|
| 862 |
"### Using the seal text recognition subpipeline",
|
| 863 |
elem_id="use_seal_recognition_md",
|
|
|
|
| 891 |
show_label=False,
|
| 892 |
elem_id="use_table_recognition_rd",
|
| 893 |
)
|
| 894 |
+
with gr.Column(visible=False) as Layout_region_detection_Options:
|
|
|
|
|
|
|
| 895 |
layout_threshold_md = gr.Markdown(
|
| 896 |
"### Score threshold of layout region detection model",
|
| 897 |
elem_id="layout_threshold_md",
|
|
|
|
| 929 |
show_label=False,
|
| 930 |
elem_id="layout_unclip_ratio_nb",
|
| 931 |
)
|
| 932 |
+
with gr.Column(visible=False) as Text_detection_Options:
|
|
|
|
|
|
|
| 933 |
text_det_limit_type_md = gr.Markdown(
|
| 934 |
"### Image side length restriction type for text detection",
|
| 935 |
elem_id="text_det_limit_type_md",
|
|
|
|
| 1008 |
elem_id="text_rec_score_thresh_nb",
|
| 1009 |
)
|
| 1010 |
|
| 1011 |
+
with gr.Column(visible=False) as Seal_text_recognition_Options:
|
|
|
|
|
|
|
| 1012 |
seal_det_limit_type_md = gr.Markdown(
|
| 1013 |
"### Image side length restriction type for seal text detection",
|
| 1014 |
elem_id="seal_det_limit_type_md",
|
|
|
|
| 1085 |
show_label=False,
|
| 1086 |
elem_id="seal_rec_score_thresh_nb",
|
| 1087 |
)
|
| 1088 |
+
with gr.Column(visible=False) as Table_recognition_Options:
|
|
|
|
|
|
|
| 1089 |
use_ocr_results_with_table_cells_md = gr.Markdown(
|
| 1090 |
"### Cell OCR mode",
|
| 1091 |
elem_id="use_ocr_results_with_table_cells_md",
|
|
|
|
| 1350 |
)
|
| 1351 |
)
|
| 1352 |
download_all_btn = gr.Button(
|
| 1353 |
+
"📦 Download Full Results (ZIP)",
|
| 1354 |
+
elem_id="unzip-btn",
|
| 1355 |
+
variant="primary",
|
| 1356 |
+
visible=False,
|
| 1357 |
+
)
|
| 1358 |
# # Navigation bar
|
| 1359 |
with gr.Column(elem_classes=["nav-bar"]):
|
| 1360 |
gr.HTML(
|
|
|
|
| 1392 |
""",
|
| 1393 |
)
|
| 1394 |
process_btn.click(
|
| 1395 |
+
toggle_spinner,
|
| 1396 |
+
outputs=[
|
| 1397 |
+
loading_spinner,
|
| 1398 |
+
prepare_spinner,
|
| 1399 |
+
download_file,
|
| 1400 |
+
tabs,
|
| 1401 |
+
download_all_btn,
|
| 1402 |
+
],
|
| 1403 |
).then(
|
| 1404 |
process_file,
|
| 1405 |
inputs=[
|
|
|
|
| 1447 |
+ output_json_list
|
| 1448 |
+ markdown_display_list
|
| 1449 |
+ gallery_list,
|
| 1450 |
+
).success(
|
| 1451 |
+
lambda: gr.update(visible=True), outputs=download_all_btn
|
| 1452 |
+
)
|
| 1453 |
|
| 1454 |
gallery_markdown.select(
|
| 1455 |
update_markdown,
|