hassan526 commited on
Commit
55286be
·
verified ·
1 Parent(s): 6592f02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -233,19 +233,22 @@ def check_liveness(frame):
233
  screenReply = float(result_dict["screenReply"])
234
  portraitReplace = float(result_dict["portraitReplace"])
235
  printedCopy = float(result_dict["printedCopy"])
236
- detResult = "genuine"
237
-
238
  # Check for "Spoof" condition
239
  if screenReply < screenReplayThreshold or portraitReplace < portraitReplaceThreshold or printedCopy < printedCopyThreshold:
240
- detResult = "spoof"
241
-
 
 
 
242
  # Update json_result with the modified process_results
243
  sys.stdout.flush()
244
- return {"status": "ok", "data": {"result": detResult, "screenreplay_integrity_score": screenReply, "portraitreplace_integrity_score": portraitReplace, "printedcutout_integrity_score": printedCopy}}
245
-
 
246
  sys.stdout.flush()
247
- return {"status": "error", "result": "document not found!"}
248
-
249
 
250
  def idcard_recognition(frame1, frame2):
251
  # url = "https://recognito-iddocumentrecognition.p.rapidapi.com/api/read_idcard"
 
233
  screenReply = float(result_dict["screenReply"])
234
  portraitReplace = float(result_dict["portraitReplace"])
235
  printedCopy = float(result_dict["printedCopy"])
236
+ liveness_result = f"""<div class="markdown-success-container"><p style="text-align: center; font-size: 20px; color: green;">Liveness Check: GENUINE</p></div>"""
237
+
238
  # Check for "Spoof" condition
239
  if screenReply < screenReplayThreshold or portraitReplace < portraitReplaceThreshold or printedCopy < printedCopyThreshold:
240
+ liveness_result = f"""<div class="markdown-fail-container"><p style="text-align: center; font-size: 20px; color: red;">Liveness Check: SPOOF</p></div>"""
241
+
242
+ json_output = {"Screen Replay Check": "Failed" if screenReply < screenReplayThreshold else "Success",
243
+ "Portrait Replace Check": "Failed" if portraitReplace < portraitReplaceThreshold else "Success",
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"