Update app.py
Browse files
app.py
CHANGED
@@ -218,7 +218,7 @@ def check_liveness(frame):
|
|
218 |
global g_id_live_activation_result
|
219 |
if g_id_live_activation_result != 0:
|
220 |
gr.Warning("ID LIVE SDK Activation Failed!")
|
221 |
-
return {"status": "error", "result": "activation error!"}
|
222 |
try:
|
223 |
image = Image.open(frame)
|
224 |
image = apply_exif_rotation(image.convert('RGB'))
|
@@ -244,11 +244,11 @@ def check_liveness(frame):
|
|
244 |
"Printed Cutout Check": "Failed" if printedCopy < printedCopyThreshold else "Success"}
|
245 |
# Update json_result with the modified process_results
|
246 |
sys.stdout.flush()
|
247 |
-
return [liveness_result, json_output]
|
248 |
|
249 |
liveness_result = f"""<div class="markdown-fail-container"><p style="text-align: center; font-size: 20px; color: red;">Liveness Check Failed</p></div>"""
|
250 |
sys.stdout.flush()
|
251 |
-
return [liveness_result, {"status": "error", "result": "document not found!"}]
|
252 |
|
253 |
def idcard_recognition(frame1, frame2):
|
254 |
# url = "https://recognito-iddocumentrecognition.p.rapidapi.com/api/read_idcard"
|
@@ -464,9 +464,12 @@ def launch_demo():
|
|
464 |
check_liveness_button = gr.Button("Check Document Liveness", variant="primary", size="lg")
|
465 |
|
466 |
liveness_result = gr.Markdown("")
|
467 |
-
|
|
|
|
|
|
|
468 |
|
469 |
-
check_liveness_button.click(check_liveness, inputs=id_image_input, outputs=[liveness_result, json_output])
|
470 |
|
471 |
gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Frecognito%2FID-Document-Verification"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Frecognito%2FID-Document-Verification&labelColor=%2337d67a&countColor=%23263759&style=flat" /></a>')
|
472 |
|
|
|
218 |
global g_id_live_activation_result
|
219 |
if g_id_live_activation_result != 0:
|
220 |
gr.Warning("ID LIVE SDK Activation Failed!")
|
221 |
+
return {"status": "error", "result": "activation error!", None}
|
222 |
try:
|
223 |
image = Image.open(frame)
|
224 |
image = apply_exif_rotation(image.convert('RGB'))
|
|
|
244 |
"Printed Cutout Check": "Failed" if printedCopy < printedCopyThreshold else "Success"}
|
245 |
# Update json_result with the modified process_results
|
246 |
sys.stdout.flush()
|
247 |
+
return [liveness_result, json_output, result_dict]
|
248 |
|
249 |
liveness_result = f"""<div class="markdown-fail-container"><p style="text-align: center; font-size: 20px; color: red;">Liveness Check Failed</p></div>"""
|
250 |
sys.stdout.flush()
|
251 |
+
return [liveness_result, {"status": "error", "result": "document not found!"}, None]
|
252 |
|
253 |
def idcard_recognition(frame1, frame2):
|
254 |
# url = "https://recognito-iddocumentrecognition.p.rapidapi.com/api/read_idcard"
|
|
|
464 |
check_liveness_button = gr.Button("Check Document Liveness", variant="primary", size="lg")
|
465 |
|
466 |
liveness_result = gr.Markdown("")
|
467 |
+
with gr.Tab("Result"):
|
468 |
+
json_output = gr.JSON()
|
469 |
+
with gr.Tab("Raw JSON"):
|
470 |
+
raw_output = gr.JSON()
|
471 |
|
472 |
+
check_liveness_button.click(check_liveness, inputs=id_image_input, outputs=[liveness_result, json_output, raw_output])
|
473 |
|
474 |
gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Frecognito%2FID-Document-Verification"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2Frecognito%2FID-Document-Verification&labelColor=%2337d67a&countColor=%23263759&style=flat" /></a>')
|
475 |
|