Spaces:
Sleeping
Sleeping
fixed checkbox
Browse files- .dockerignore +1 -1
- app.py +11 -6
- src/htr_pipeline/gradio_backend.py +6 -4
.dockerignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
.github/
|
2 |
__pycache__
|
3 |
*.pyc
|
4 |
*.pyo
|
|
|
1 |
+
# .github/
|
2 |
__pycache__
|
3 |
*.pyc
|
4 |
*.pyo
|
app.py
CHANGED
@@ -26,7 +26,7 @@ with gr.Blocks(title="HTR Riksarkivet", theme=theme, css=css) as demo:
|
|
26 |
label="Image to run HTR on", type="numpy", tool="editor", elem_id="image_upload"
|
27 |
).style(height=395)
|
28 |
|
29 |
-
with gr.Row():
|
30 |
# with gr.Group():
|
31 |
# callback = gr.CSVLogger()
|
32 |
# # hf_writer = gr.HuggingFaceDatasetSaver(HF_API_TOKEN, "htr_pipelin_flags")
|
@@ -35,18 +35,23 @@ with gr.Blocks(title="HTR Riksarkivet", theme=theme, css=css) as demo:
|
|
35 |
# variant="secondary",
|
36 |
# visible=True,
|
37 |
# ).style(full_width=True)
|
38 |
-
radio_file_input = gr.Radio(
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
)
|
41 |
-
with gr.Row():
|
42 |
-
htr_clear_button = gr.Button("", variant="Secondary")
|
43 |
|
44 |
htr_pipeline_button = gr.Button(
|
45 |
"Run HTR",
|
46 |
variant="primary",
|
47 |
visible=True,
|
48 |
elem_id="run_pipeline_button",
|
49 |
-
).style(full_width=
|
50 |
|
51 |
with gr.Group():
|
52 |
with gr.Row():
|
|
|
26 |
label="Image to run HTR on", type="numpy", tool="editor", elem_id="image_upload"
|
27 |
).style(height=395)
|
28 |
|
29 |
+
with gr.Row(equal_height=False):
|
30 |
# with gr.Group():
|
31 |
# callback = gr.CSVLogger()
|
32 |
# # hf_writer = gr.HuggingFaceDatasetSaver(HF_API_TOKEN, "htr_pipelin_flags")
|
|
|
35 |
# variant="secondary",
|
36 |
# visible=True,
|
37 |
# ).style(full_width=True)
|
38 |
+
# radio_file_input = gr.Radio(
|
39 |
+
# value="Text file", choices=["Text file ", "Page XML file "], label="What kind file output?"
|
40 |
+
# )
|
41 |
+
|
42 |
+
radio_file_input = gr.CheckboxGroup(
|
43 |
+
choices=["Txt", "Page XML"],
|
44 |
+
value=["Txt"],
|
45 |
+
label="Output file extension",
|
46 |
+
# info="Only txt and page xml is supported for now!",
|
47 |
)
|
|
|
|
|
48 |
|
49 |
htr_pipeline_button = gr.Button(
|
50 |
"Run HTR",
|
51 |
variant="primary",
|
52 |
visible=True,
|
53 |
elem_id="run_pipeline_button",
|
54 |
+
).style(full_width=False)
|
55 |
|
56 |
with gr.Group():
|
57 |
with gr.Row():
|
src/htr_pipeline/gradio_backend.py
CHANGED
@@ -38,11 +38,13 @@ class FastTrack:
|
|
38 |
f.write(rendered_xml)
|
39 |
|
40 |
xml_img = self.visualize_xml_and_return_txt(image, xml_txt)
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
else:
|
45 |
-
returned_file_extension = xml_xml
|
46 |
|
47 |
return xml_img, returned_file_extension, gr.update(visible=True)
|
48 |
|
|
|
38 |
f.write(rendered_xml)
|
39 |
|
40 |
xml_img = self.visualize_xml_and_return_txt(image, xml_txt)
|
41 |
+
if len(radio_button_choices) < 2:
|
42 |
+
if radio_button_choices[0] == "Txt":
|
43 |
+
returned_file_extension = xml_txt
|
44 |
+
else:
|
45 |
+
returned_file_extension = xml_xml
|
46 |
else:
|
47 |
+
returned_file_extension = [xml_txt, xml_xml]
|
48 |
|
49 |
return xml_img, returned_file_extension, gr.update(visible=True)
|
50 |
|