Spaces:
Running
Running
UI improvements
Browse files- Use a tabbed interface for upload/canvas image
- Hide detailed output by default. Allow toggling.
app.py
CHANGED
@@ -71,27 +71,28 @@ def main():
|
|
71 |
|
72 |
To use this interactive demo for PARSeq and reproduced models:
|
73 |
1. Select which model you want to use.
|
74 |
-
2. Upload your own image
|
75 |
-
3. Click **Read
|
76 |
|
77 |
*NOTE*: None of these models were trained on handwritten text datasets.
|
78 |
""")
|
79 |
model_name = gr.Radio(app.models, value=app.models[0], label='The STR model to use')
|
80 |
-
with gr.
|
81 |
-
with gr.
|
82 |
image_upload = gr.Image(type='pil', source='upload', label='Image')
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
87 |
|
88 |
output = gr.Textbox(max_lines=1, label='Model output')
|
89 |
-
|
90 |
-
|
91 |
-
gr.Examples(glob.glob('demo_images/*.*'), inputs=image_upload)
|
92 |
|
93 |
read_upload.click(app, inputs=[model_name, image_upload], outputs=[output, raw_output])
|
94 |
read_canvas.click(app, inputs=[model_name, image_canvas], outputs=[output, raw_output])
|
|
|
95 |
|
96 |
demo.launch()
|
97 |
|
|
|
71 |
|
72 |
To use this interactive demo for PARSeq and reproduced models:
|
73 |
1. Select which model you want to use.
|
74 |
+
2. Upload your own cropped image (or select from the given examples), or sketch on the canvas.
|
75 |
+
3. Click **Read Text**.
|
76 |
|
77 |
*NOTE*: None of these models were trained on handwritten text datasets.
|
78 |
""")
|
79 |
model_name = gr.Radio(app.models, value=app.models[0], label='The STR model to use')
|
80 |
+
with gr.Tabs():
|
81 |
+
with gr.TabItem('Image Upload'):
|
82 |
image_upload = gr.Image(type='pil', source='upload', label='Image')
|
83 |
+
gr.Examples(glob.glob('demo_images/*.*'), inputs=image_upload)
|
84 |
+
read_upload = gr.Button('Read Text')
|
85 |
+
with gr.TabItem('Canvas Sketch'):
|
86 |
+
image_canvas = gr.Image(type='pil', source='canvas', label='Sketch')
|
87 |
+
read_canvas = gr.Button('Read Text')
|
88 |
|
89 |
output = gr.Textbox(max_lines=1, label='Model output')
|
90 |
+
adv_output = gr.Checkbox(label='Show detailed output')
|
91 |
+
raw_output = gr.Dataframe(row_count=2, col_count=0, label='Raw output with confidence values ([0, 1] interval; [B] - BLANK token; [E] - EOS token)', visible=False)
|
|
|
92 |
|
93 |
read_upload.click(app, inputs=[model_name, image_upload], outputs=[output, raw_output])
|
94 |
read_canvas.click(app, inputs=[model_name, image_canvas], outputs=[output, raw_output])
|
95 |
+
adv_output.change(lambda x: gr.update(visible=x), inputs=adv_output, outputs=raw_output)
|
96 |
|
97 |
demo.launch()
|
98 |
|