Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
CSV_PATH = "/judged-fast-accurate-downsampled.csv"
|
| 5 |
|
| 6 |
|
| 7 |
def load_csv_from_path(path: str):
|
|
@@ -87,6 +87,13 @@ def filter_rows(df, mode, similar, text_filter, max_rows):
|
|
| 87 |
return "", summary, subset
|
| 88 |
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
with gr.Blocks() as demo:
|
| 91 |
gr.Markdown("# OCR Judge Viewer")
|
| 92 |
with gr.Row():
|
|
@@ -99,15 +106,13 @@ with gr.Blocks() as demo:
|
|
| 99 |
err_box = gr.Markdown()
|
| 100 |
summary_box = gr.Markdown()
|
| 101 |
table = gr.Dataframe(wrap=True)
|
| 102 |
-
data_state = gr.State(None)
|
| 103 |
|
| 104 |
-
reload_btn.click(
|
| 105 |
-
|
| 106 |
-
)
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
max_rows.change(filter_rows, [data_state, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
| 113 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, ssr_mode=False, show_error=True)
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
CSV_PATH = "./judged-fast-accurate-downsampled.csv"
|
| 5 |
|
| 6 |
|
| 7 |
def load_csv_from_path(path: str):
|
|
|
|
| 87 |
return "", summary, subset
|
| 88 |
|
| 89 |
|
| 90 |
+
def run_all(path, mode, similar, text_filter, max_rows):
|
| 91 |
+
df, err = load_csv_from_path(path)
|
| 92 |
+
if err:
|
| 93 |
+
return err, "", None
|
| 94 |
+
return filter_rows(df, mode, similar, text_filter, max_rows)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
with gr.Blocks() as demo:
|
| 98 |
gr.Markdown("# OCR Judge Viewer")
|
| 99 |
with gr.Row():
|
|
|
|
| 106 |
err_box = gr.Markdown()
|
| 107 |
summary_box = gr.Markdown()
|
| 108 |
table = gr.Dataframe(wrap=True)
|
|
|
|
| 109 |
|
| 110 |
+
reload_btn.click(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 111 |
+
mode.change(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 112 |
+
similar.change(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 113 |
+
text_filter.change(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 114 |
+
max_rows.change(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
| 115 |
+
demo.load(run_all, [path_in, mode, similar, text_filter, max_rows], [err_box, summary_box, table])
|
|
|
|
| 116 |
|
| 117 |
if __name__ == "__main__":
|
| 118 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, ssr_mode=False, show_error=True)
|