Spaces:
Runtime error
Runtime error
Update
Browse files- demo.py +17 -5
- examples/c1.jpg +0 -0
- examples/c2.jpg +0 -0
- examples/c3.jpg +0 -0
demo.py
CHANGED
|
@@ -138,6 +138,10 @@ def credit_recognition(frame):
|
|
| 138 |
json_result = json.dumps(resultValues, indent=4)
|
| 139 |
return [json_result, images]
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
with gr.Blocks() as demo:
|
| 142 |
gr.Markdown(
|
| 143 |
"""
|
|
@@ -156,7 +160,7 @@ with gr.Blocks() as demo:
|
|
| 156 |
id_image_input1 = gr.Image(type='filepath', label='Front')
|
| 157 |
id_image_input2 = gr.Image(type='filepath', label='Back')
|
| 158 |
id_recognition_button = gr.Button("ID Card Recognition")
|
| 159 |
-
gr.Markdown("##
|
| 160 |
gr.Examples(
|
| 161 |
examples=[['examples/11.jpg', 'examples/12.jpg'], ['examples/21.jpg', 'examples/22.jpg'], ['examples/3.jpg', '']],
|
| 162 |
inputs=[id_image_input1, id_image_input2],
|
|
@@ -165,10 +169,10 @@ with gr.Blocks() as demo:
|
|
| 165 |
)
|
| 166 |
|
| 167 |
with gr.Column(scale=5):
|
| 168 |
-
id_result_output
|
| 169 |
|
| 170 |
with gr.Column(scale=2):
|
| 171 |
-
image_result_output
|
| 172 |
|
| 173 |
id_recognition_button.click(idcard_recognition, inputs=[id_image_input1, id_image_input2], outputs=[id_result_output, image_result_output])
|
| 174 |
with gr.TabItem("Barcode Recognition"):
|
|
@@ -189,11 +193,19 @@ with gr.Blocks() as demo:
|
|
| 189 |
with gr.Column(scale=3):
|
| 190 |
credit_image_input = gr.Image(type='filepath')
|
| 191 |
credit_recognition_button = gr.Button("Credit Card Recognition")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
with gr.Column(scale=5):
|
| 193 |
-
credit_result_output
|
| 194 |
|
| 195 |
with gr.Column(scale=2):
|
| 196 |
-
image_result_output
|
| 197 |
|
| 198 |
credit_recognition_button.click(credit_recognition, inputs=credit_image_input, outputs=[credit_result_output, image_result_output])
|
| 199 |
|
|
|
|
| 138 |
json_result = json.dumps(resultValues, indent=4)
|
| 139 |
return [json_result, images]
|
| 140 |
|
| 141 |
+
id_result_output = gr.JSON()
|
| 142 |
+
image_result_output = gr.HTML()
|
| 143 |
+
credit_result_output = gr.JSON()
|
| 144 |
+
image_result_output = gr.HTML()
|
| 145 |
with gr.Blocks() as demo:
|
| 146 |
gr.Markdown(
|
| 147 |
"""
|
|
|
|
| 160 |
id_image_input1 = gr.Image(type='filepath', label='Front')
|
| 161 |
id_image_input2 = gr.Image(type='filepath', label='Back')
|
| 162 |
id_recognition_button = gr.Button("ID Card Recognition")
|
| 163 |
+
gr.Markdown("## Examples")
|
| 164 |
gr.Examples(
|
| 165 |
examples=[['examples/11.jpg', 'examples/12.jpg'], ['examples/21.jpg', 'examples/22.jpg'], ['examples/3.jpg', '']],
|
| 166 |
inputs=[id_image_input1, id_image_input2],
|
|
|
|
| 169 |
)
|
| 170 |
|
| 171 |
with gr.Column(scale=5):
|
| 172 |
+
id_result_output
|
| 173 |
|
| 174 |
with gr.Column(scale=2):
|
| 175 |
+
image_result_output
|
| 176 |
|
| 177 |
id_recognition_button.click(idcard_recognition, inputs=[id_image_input1, id_image_input2], outputs=[id_result_output, image_result_output])
|
| 178 |
with gr.TabItem("Barcode Recognition"):
|
|
|
|
| 193 |
with gr.Column(scale=3):
|
| 194 |
credit_image_input = gr.Image(type='filepath')
|
| 195 |
credit_recognition_button = gr.Button("Credit Card Recognition")
|
| 196 |
+
gr.Markdown("## Examples")
|
| 197 |
+
gr.Examples(
|
| 198 |
+
examples=['examples/c1.jpg', 'examples/c2.jpg', 'examples/c3.jpg'],
|
| 199 |
+
inputs=credit_image_input,
|
| 200 |
+
outputs=[credit_result_output, image_result_output],
|
| 201 |
+
fn=credit_recognition
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
with gr.Column(scale=5):
|
| 205 |
+
credit_result_output
|
| 206 |
|
| 207 |
with gr.Column(scale=2):
|
| 208 |
+
image_result_output
|
| 209 |
|
| 210 |
credit_recognition_button.click(credit_recognition, inputs=credit_image_input, outputs=[credit_result_output, image_result_output])
|
| 211 |
|
examples/c1.jpg
ADDED
|
examples/c2.jpg
ADDED
|
examples/c3.jpg
ADDED
|