rakibulinux commited on
Commit
ac33358
·
1 Parent(s): 7cca175

Fixed UI issue

Browse files
Files changed (1) hide show
  1. ui.py +22 -25
ui.py CHANGED
@@ -88,40 +88,37 @@ def create_interface():
88
  image_input = gr.Image(label="Upload Image")
89
  submit_btn = gr.Button("Read Document", variant="primary", size="lg")
90
 
91
- id_examples = gr.Examples(
92
- examples=ID_EXAMPLES,
93
- inputs=image_input,
94
- label="ID Card Examples",
95
- visible=True,
96
- )
97
- credit_examples = gr.Examples(
98
- examples=CREDIT_EXAMPLES,
99
- inputs=image_input,
100
- label="Credit Card Examples",
101
- visible=False,
102
- )
103
- mrz_examples = gr.Examples(
104
- examples=MRZ_EXAMPLES,
105
- inputs=image_input,
106
- label="MRZ / Barcode Examples",
107
- visible=False,
108
- )
109
 
110
  with gr.Column(scale=1, min_width=400):
111
  result_html = gr.HTML(label="Extracted Data")
112
  raw_json = gr.JSON(label="Raw Response")
113
 
114
- def on_type_change(choice):
115
- return (
116
  gr.update(visible=choice == "ID"),
117
  gr.update(visible=choice == "Credit Card"),
118
  gr.update(visible=choice == "MRZ"),
119
- )
120
-
121
- doc_type.change(
122
- fn=on_type_change,
123
  inputs=doc_type,
124
- outputs=[id_examples, credit_examples, mrz_examples],
125
  )
126
 
127
  submit_btn.click(
 
88
  image_input = gr.Image(label="Upload Image")
89
  submit_btn = gr.Button("Read Document", variant="primary", size="lg")
90
 
91
+ with gr.Column(visible=True) as id_col:
92
+ gr.Examples(
93
+ examples=ID_EXAMPLES,
94
+ inputs=image_input,
95
+ label="ID Card Examples",
96
+ )
97
+ with gr.Column(visible=False) as credit_col:
98
+ gr.Examples(
99
+ examples=CREDIT_EXAMPLES,
100
+ inputs=image_input,
101
+ label="Credit Card Examples",
102
+ )
103
+ with gr.Column(visible=False) as mrz_col:
104
+ gr.Examples(
105
+ examples=MRZ_EXAMPLES,
106
+ inputs=image_input,
107
+ label="MRZ / Barcode Examples",
108
+ )
109
 
110
  with gr.Column(scale=1, min_width=400):
111
  result_html = gr.HTML(label="Extracted Data")
112
  raw_json = gr.JSON(label="Raw Response")
113
 
114
+ doc_type.change(
115
+ fn=lambda choice: (
116
  gr.update(visible=choice == "ID"),
117
  gr.update(visible=choice == "Credit Card"),
118
  gr.update(visible=choice == "MRZ"),
119
+ ),
 
 
 
120
  inputs=doc_type,
121
+ outputs=[id_col, credit_col, mrz_col],
122
  )
123
 
124
  submit_btn.click(