justin2341 commited on
Commit
c5e21cb
·
verified ·
1 Parent(s): 497f61b

Upload demo.py

Browse files
Files changed (1) hide show
  1. demo.py +80 -0
demo.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ from PIL import Image
4
+ import io
5
+ import cv2
6
+ import numpy as np
7
+
8
+ palmprint_count = 0
9
+
10
+ def compare_palmprint(frame1, frame2):
11
+ global palmprint_count
12
+
13
+ palmprint_count = palmprint_count + 1
14
+
15
+ url = "http://127.0.0.1:8080/compare_palmprint"
16
+ files = {'file1': open(frame1, 'rb'), 'file2': open(frame2, 'rb')}
17
+
18
+ r = requests.post(url=url, files=files)
19
+
20
+ html = None
21
+
22
+ compare_result = r.json().get('compare_result')
23
+ compare_similarity = r.json().get('compare_similarity')
24
+
25
+ html = ("<table>"
26
+ "<tr>"
27
+ "<th>Compare Result</th>"
28
+ "<th>Value</th>"
29
+ "</tr>"
30
+ "<tr>"
31
+ "<td>Result</td>"
32
+ "<td>{compare_result}</td>"
33
+ "</tr>"
34
+ "<tr>"
35
+ "<td>Similarity</td>"
36
+ "<td>{compare_similarity}</td>"
37
+ "</tr>"
38
+ "</table>".format(compare_result=compare_result, compare_similarity=compare_similarity))
39
+
40
+ return [html]
41
+
42
+ with gr.Blocks() as demo:
43
+ gr.Markdown(
44
+ """
45
+ # KBY-AI Palm-Print Recognition
46
+ We offer SDKs for face recognition, liveness detection(anti-spoofing), ID card recognition and ID document liveness detection.
47
+ We also specialize in providing outsourcing services with a variety of technical stacks like AI(Computer Vision/Machine Learning), Mobile apps, and web apps.
48
+
49
+ ##### KYC Verification Demo - https://github.com/kby-ai/KYC-Verification-Demo-Android
50
+ ##### ID Capture Web Demo - https://cap.kby-ai.com
51
+ """
52
+ )
53
+
54
+ with gr.TabItem("Palmprint Recognition"):
55
+ gr.Markdown(
56
+ """
57
+ ##### Docker Hub - https://hub.docker.com/r/kbyai/palmprint-recognition
58
+ ```bash
59
+ sudo docker pull kbyai/palmprint-recognition:latest
60
+ sudo docker run -v ./license.txt:/root/kby-ai-palmprint/license.txt -p 8081:8080 -p 9001:9000 kbyai/palmprint-recognition:latest
61
+ ```
62
+ """
63
+ )
64
+ with gr.Row():
65
+ with gr.Column():
66
+ compare_palmprint_input1 = gr.Image(type='filepath')
67
+ gr.Examples(['palmprint_examples/1.jpg', 'palmprint_examples/3.jpg', 'palmprint_examples/5.jpg', 'palmprint_examples/7.jpg'],
68
+ inputs=compare_palmprint_input1)
69
+ compare_palmprint_button = gr.Button("Compare Hand")
70
+ with gr.Column():
71
+ compare_palmprint_input2 = gr.Image(type='filepath')
72
+ gr.Examples(['palmprint_examples/2.jpg', 'palmprint_examples/4.jpg', 'palmprint_examples/6.jpg', 'palmprint_examples/8.jpg'],
73
+ inputs=compare_palmprint_input2)
74
+ with gr.Column():
75
+ compare_result_output = gr.HTML(label='Result')
76
+
77
+ compare_palmprint_button.click(compare_palmprint, inputs=[compare_palmprint_input1, compare_palmprint_input2], outputs=[compare_result_output])
78
+ gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fweb.kby-ai.com%2F"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fweb.kby-ai.com%2F&label=VISITORS&countColor=%23263759" /></a>')
79
+
80
+ demo.launch(server_name="0.0.0.0", server_port=7860)