Ubuntu
commited on
Commit
·
1f092df
1
Parent(s):
0cfa27c
Adding application
Browse files- app.py +76 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
def check_idlive(frame):
|
| 6 |
+
url = "https://api.miniai.live/api/id_check"
|
| 7 |
+
files = {'image': open(frame, 'rb')}
|
| 8 |
+
|
| 9 |
+
r = requests.post(url=url, files=files)
|
| 10 |
+
|
| 11 |
+
status = r.json().get('Status')
|
| 12 |
+
table_value = ""
|
| 13 |
+
|
| 14 |
+
html = ("<table>"
|
| 15 |
+
"<tr>"
|
| 16 |
+
"<th style=""width:20%"">Field</th>"
|
| 17 |
+
"<th style=""width:40%"">Value</th>"
|
| 18 |
+
"<th style=""width:40%"">MRZ</th>"
|
| 19 |
+
"</tr>"
|
| 20 |
+
"{table_value}"
|
| 21 |
+
"</table>".format(table_value=table_value))
|
| 22 |
+
|
| 23 |
+
images = ("<table>"
|
| 24 |
+
"<tr>"
|
| 25 |
+
"<th>Field</th>"
|
| 26 |
+
"<th>Image</th>"
|
| 27 |
+
"</tr>"
|
| 28 |
+
"{table_value}"
|
| 29 |
+
"</table>".format(table_value=table_value))
|
| 30 |
+
|
| 31 |
+
return [html, images]
|
| 32 |
+
|
| 33 |
+
# APP Interface
|
| 34 |
+
with gr.Blocks() as MiniAIdemo:
|
| 35 |
+
gr.Markdown(
|
| 36 |
+
"""
|
| 37 |
+
<a href="https://miniai.live" style="display: flex; align-items: center;">
|
| 38 |
+
<img src="https://miniai.live/wp-content/uploads/2024/02/logo_name-1-768x426-1.png" style="width: 18%; margin-right: 15px;"/>
|
| 39 |
+
<div>
|
| 40 |
+
<p style="font-size: 50px; font-weight: bold; margin-right: 20px;">ID Document Liveness WebAPI Demo</p>
|
| 41 |
+
</div>
|
| 42 |
+
</a>
|
| 43 |
+
|
| 44 |
+
<br/>
|
| 45 |
+
<ul>
|
| 46 |
+
<li style="font-size: 18px;">Visit and learn more about our Service : <a href="https://miniai.live" target="_blank" style="font-size: 18px;">https://www.miniai.live</a></li>
|
| 47 |
+
<li style="font-size: 18px;">Check our SDK for cross-platform from Github : <a href="https://github.com/MiniAiLive" target="_blank" style="font-size: 18px;">https://github.com/MiniAiLive</a></li>
|
| 48 |
+
<li style="font-size: 18px;">Quick view our Youtube Demo Video : <a href="https://www.youtube.com/@miniailive" target="_blank" style="font-size: 18px;">MiniAiLive Youtube Channel</a></li>
|
| 49 |
+
<li style="font-size: 18px;">Demo with Android device from Google Play : <a href="https://play.google.com/store/apps/dev?id=5831076207730531667" target="_blank" style="font-size: 18px;">MiniAiLive Google Play</a></li>
|
| 50 |
+
</ul>
|
| 51 |
+
<br/>
|
| 52 |
+
"""
|
| 53 |
+
)
|
| 54 |
+
with gr.Tabs():
|
| 55 |
+
with gr.Tab("ID Document Liveness"):
|
| 56 |
+
with gr.Row():
|
| 57 |
+
with gr.Column(scale=3):
|
| 58 |
+
im_idlive_in = gr.Image(type='filepath', height=300)
|
| 59 |
+
gr.Examples(
|
| 60 |
+
[
|
| 61 |
+
"images/id/demo1.jpg",
|
| 62 |
+
"images/id/demo2.png",
|
| 63 |
+
"images/id/demo3.png",
|
| 64 |
+
],
|
| 65 |
+
inputs=im_idlive_in
|
| 66 |
+
)
|
| 67 |
+
btn_f_idlive = gr.Button("Check Document Liveness", variant='primary')
|
| 68 |
+
with gr.Column(scale=5):
|
| 69 |
+
table_idlive_out = gr.HTML()
|
| 70 |
+
with gr.Column(scale=2):
|
| 71 |
+
im_idlive_out = gr.HTML()
|
| 72 |
+
|
| 73 |
+
btn_f_idlive.click(check_idlive, inputs=im_idlive_in, outputs=[table_idlive_out, im_idlive_out])
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
MiniAIdemo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
requests
|