Ubuntu
Adding application
1f092df
raw
history blame
3.19 kB
import gradio as gr
import requests
from PIL import Image
def check_idlive(frame):
url = "https://api.miniai.live/api/id_check"
files = {'image': open(frame, 'rb')}
r = requests.post(url=url, files=files)
status = r.json().get('Status')
table_value = ""
html = ("<table>"
"<tr>"
"<th style=""width:20%"">Field</th>"
"<th style=""width:40%"">Value</th>"
"<th style=""width:40%"">MRZ</th>"
"</tr>"
"{table_value}"
"</table>".format(table_value=table_value))
images = ("<table>"
"<tr>"
"<th>Field</th>"
"<th>Image</th>"
"</tr>"
"{table_value}"
"</table>".format(table_value=table_value))
return [html, images]
# APP Interface
with gr.Blocks() as MiniAIdemo:
gr.Markdown(
"""
<a href="https://miniai.live" style="display: flex; align-items: center;">
<img src="https://miniai.live/wp-content/uploads/2024/02/logo_name-1-768x426-1.png" style="width: 18%; margin-right: 15px;"/>
<div>
<p style="font-size: 50px; font-weight: bold; margin-right: 20px;">ID Document Liveness WebAPI Demo</p>
</div>
</a>
<br/>
<ul>
<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>
<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>
<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>
<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>
</ul>
<br/>
"""
)
with gr.Tabs():
with gr.Tab("ID Document Liveness"):
with gr.Row():
with gr.Column(scale=3):
im_idlive_in = gr.Image(type='filepath', height=300)
gr.Examples(
[
"images/id/demo1.jpg",
"images/id/demo2.png",
"images/id/demo3.png",
],
inputs=im_idlive_in
)
btn_f_idlive = gr.Button("Check Document Liveness", variant='primary')
with gr.Column(scale=5):
table_idlive_out = gr.HTML()
with gr.Column(scale=2):
im_idlive_out = gr.HTML()
btn_f_idlive.click(check_idlive, inputs=im_idlive_in, outputs=[table_idlive_out, im_idlive_out])
if __name__ == "__main__":
MiniAIdemo.launch()