Spaces:
Running
Running
Upload demo.py
Browse files
demo.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
print("palmprint_count", palmprint_count)
|
15 |
+
f = open('palmprint_recognition.txt', 'w', encoding="utf-8")
|
16 |
+
f.write("palmprint_count: {palmprint_count}".format(palmprint_count=palmprint_count))
|
17 |
+
f.close()
|
18 |
+
|
19 |
+
url = "http://127.0.0.1:8080/compare_palmprint"
|
20 |
+
files = {'file1': open(frame1, 'rb'), 'file2': open(frame2, 'rb')}
|
21 |
+
|
22 |
+
r = requests.post(url=url, files=files)
|
23 |
+
|
24 |
+
html = None
|
25 |
+
|
26 |
+
compare_result = r.json().get('compare_result')
|
27 |
+
compare_similarity = r.json().get('compare_similarity')
|
28 |
+
|
29 |
+
html = ("<table>"
|
30 |
+
"<tr>"
|
31 |
+
"<th>Compare Result</th>"
|
32 |
+
"<th>Value</th>"
|
33 |
+
"</tr>"
|
34 |
+
"<tr>"
|
35 |
+
"<td>Result</td>"
|
36 |
+
"<td>{compare_result}</td>"
|
37 |
+
"</tr>"
|
38 |
+
"<tr>"
|
39 |
+
"<td>Similarity</td>"
|
40 |
+
"<td>{compare_similarity}</td>"
|
41 |
+
"</tr>"
|
42 |
+
"</table>".format(compare_result=compare_result, compare_similarity=compare_similarity))
|
43 |
+
|
44 |
+
return [html]
|
45 |
+
|
46 |
+
with gr.Blocks() as demo:
|
47 |
+
gr.Markdown(
|
48 |
+
"""
|
49 |
+
# KBY-AI Palm-Print Recognition
|
50 |
+
We offer SDKs for face recognition, liveness detection(anti-spoofing), ID card recognition and ID document liveness detection.
|
51 |
+
We also specialize in providing outsourcing services with a variety of technical stacks like AI(Computer Vision/Machine Learning), Mobile apps, and web apps.
|
52 |
+
|
53 |
+
##### KYC Verification Demo - https://github.com/kby-ai/KYC-Verification-Demo-Android
|
54 |
+
##### ID Capture Web Demo - https://id-document-recognition-react-alpha.vercel.app
|
55 |
+
"""
|
56 |
+
)
|
57 |
+
|
58 |
+
with gr.TabItem("Palmprint Recognition"):
|
59 |
+
gr.Markdown(
|
60 |
+
"""
|
61 |
+
##### Docker Hub - https://hub.docker.com/r/kbyai/palmprint-recognition
|
62 |
+
```bash
|
63 |
+
sudo docker pull kbyai/palmprint-recognition:latest
|
64 |
+
sudo docker run -v ./license.txt:/root/kby-ai-palmprint/license.txt -p 8081:8080 -p 9001:9000 kbyai/palmprint-recognition:latest
|
65 |
+
```
|
66 |
+
"""
|
67 |
+
)
|
68 |
+
with gr.Row():
|
69 |
+
with gr.Column():
|
70 |
+
compare_palmprint_input1 = gr.Image(type='filepath')
|
71 |
+
gr.Examples(['palmprint_examples/1.jpg', 'palmprint_examples/3.jpg', 'palmprint_examples/5.jpg', 'palmprint_examples/7.jpg', 'palmprint_examples/9.jpg'],
|
72 |
+
inputs=compare_palmprint_input1)
|
73 |
+
compare_palmprint_button = gr.Button("Compare Hand")
|
74 |
+
with gr.Column():
|
75 |
+
compare_palmprint_input2 = gr.Image(type='filepath')
|
76 |
+
gr.Examples(['palmprint_examples/2.jpg', 'palmprint_examples/4.jpg', 'palmprint_examples/6.jpg', 'palmprint_examples/8.jpg', 'palmprint_examples/10.jpg'],
|
77 |
+
inputs=compare_palmprint_input2)
|
78 |
+
with gr.Column():
|
79 |
+
compare_result_output = gr.HTML(label='Result')
|
80 |
+
|
81 |
+
compare_palmprint_button.click(compare_palmprint, inputs=[compare_palmprint_input1, compare_palmprint_input2], outputs=[compare_result_output])
|
82 |
+
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>')
|
83 |
+
|
84 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|