Spaces:
Sleeping
Sleeping
Pointf5ive commited on
Commit Β·
2e8c90b
1
Parent(s): 9737ee7
Auto-populate review item on tab open and after OCR run
Browse files- smoke_signal_tab.py +9 -8
smoke_signal_tab.py
CHANGED
|
@@ -1736,10 +1736,10 @@ def smoke_signal_tab():
|
|
| 1736 |
ocr_btn = gr.Button("Run OCR β", elem_classes=["ss-btn-run"])
|
| 1737 |
ocr_log = gr.Textbox(label="Log", lines=10, interactive=False, elem_classes=["ss-log"])
|
| 1738 |
|
| 1739 |
-
ocr_btn.click(run_ocr, outputs=[ocr_status, ocr_log])
|
| 1740 |
|
| 1741 |
# ββ STEP 4: REVIEW ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1742 |
-
with gr.TabItem("β£ Review", id="ss-review"):
|
| 1743 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1744 |
<div class="ss-panel-icon">β</div>
|
| 1745 |
<div><p class="ss-panel-title">Review Workbench</p>
|
|
@@ -1789,13 +1789,10 @@ def smoke_signal_tab():
|
|
| 1789 |
load_review_btn = gr.Button("β» Load Review Queue", elem_classes=["ss-btn-next"])
|
| 1790 |
current_idx = gr.State(0)
|
| 1791 |
|
| 1792 |
-
review_outputs = [training_feedback, review_image, raw_text_box, item_info,
|
| 1793 |
-
gr.State(), gr.State()]
|
| 1794 |
-
|
| 1795 |
def load_review():
|
| 1796 |
img, raw, info, done, total = get_review_item(0)
|
| 1797 |
status = _review_status_html()
|
| 1798 |
-
return status, img, raw, raw, info
|
| 1799 |
|
| 1800 |
def next_item(idx):
|
| 1801 |
new_idx = idx + 1
|
|
@@ -1827,10 +1824,14 @@ def smoke_signal_tab():
|
|
| 1827 |
action_outputs = [training_feedback, review_status, current_idx,
|
| 1828 |
review_image, raw_text_box, final_text_box, item_info]
|
| 1829 |
|
|
|
|
|
|
|
| 1830 |
load_review_btn.click(
|
| 1831 |
load_review,
|
| 1832 |
-
outputs=
|
| 1833 |
)
|
|
|
|
|
|
|
| 1834 |
accept_btn.click(do_accept, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
| 1835 |
edit_btn.click(do_accept, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
| 1836 |
reject_btn.click(do_reject, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
|
@@ -1844,7 +1845,7 @@ def smoke_signal_tab():
|
|
| 1844 |
next_btn.click(_next, inputs=[current_idx],
|
| 1845 |
outputs=[current_idx, review_image, raw_text_box, final_text_box, item_info])
|
| 1846 |
|
| 1847 |
-
#
|
| 1848 |
|
| 1849 |
# ββ STEP 5: EXPORT ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1850 |
with gr.TabItem("β€ Export", id="ss-export"):
|
|
|
|
| 1736 |
ocr_btn = gr.Button("Run OCR β", elem_classes=["ss-btn-run"])
|
| 1737 |
ocr_log = gr.Textbox(label="Log", lines=10, interactive=False, elem_classes=["ss-log"])
|
| 1738 |
|
| 1739 |
+
ocr_run_event = ocr_btn.click(run_ocr, outputs=[ocr_status, ocr_log])
|
| 1740 |
|
| 1741 |
# ββ STEP 4: REVIEW ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1742 |
+
with gr.TabItem("β£ Review", id="ss-review") as review_tab:
|
| 1743 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1744 |
<div class="ss-panel-icon">β</div>
|
| 1745 |
<div><p class="ss-panel-title">Review Workbench</p>
|
|
|
|
| 1789 |
load_review_btn = gr.Button("β» Load Review Queue", elem_classes=["ss-btn-next"])
|
| 1790 |
current_idx = gr.State(0)
|
| 1791 |
|
|
|
|
|
|
|
|
|
|
| 1792 |
def load_review():
|
| 1793 |
img, raw, info, done, total = get_review_item(0)
|
| 1794 |
status = _review_status_html()
|
| 1795 |
+
return 0, status, img, raw, raw, info
|
| 1796 |
|
| 1797 |
def next_item(idx):
|
| 1798 |
new_idx = idx + 1
|
|
|
|
| 1824 |
action_outputs = [training_feedback, review_status, current_idx,
|
| 1825 |
review_image, raw_text_box, final_text_box, item_info]
|
| 1826 |
|
| 1827 |
+
review_load_outputs = [current_idx, review_status, review_image, raw_text_box, final_text_box, item_info]
|
| 1828 |
+
|
| 1829 |
load_review_btn.click(
|
| 1830 |
load_review,
|
| 1831 |
+
outputs=review_load_outputs
|
| 1832 |
)
|
| 1833 |
+
review_tab.select(load_review, outputs=review_load_outputs)
|
| 1834 |
+
ocr_run_event.then(load_review, outputs=review_load_outputs)
|
| 1835 |
accept_btn.click(do_accept, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
| 1836 |
edit_btn.click(do_accept, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
| 1837 |
reject_btn.click(do_reject, inputs=[current_idx, final_text_box, reviewer_name, reason_code], outputs=action_outputs)
|
|
|
|
| 1845 |
next_btn.click(_next, inputs=[current_idx],
|
| 1846 |
outputs=[current_idx, review_image, raw_text_box, final_text_box, item_info])
|
| 1847 |
|
| 1848 |
+
# Review now auto-loads on tab select and after OCR run completion.
|
| 1849 |
|
| 1850 |
# ββ STEP 5: EXPORT ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1851 |
with gr.TabItem("β€ Export", id="ss-export"):
|