Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import os | |
| import requests | |
| import json | |
| def check_id_liveness(frame): | |
| url = "https://idlive.miniai.live/api/check_id_liveness" | |
| files = {'image': open(frame, 'rb')} | |
| try: | |
| r = requests.post(url=url, files=files) | |
| r.raise_for_status() | |
| return json.dumps(r.json(), indent=2) | |
| except requests.exceptions.RequestException as e: | |
| return str(e) | |
| # 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: 40px; font-weight: bold; margin-right: 20px;">ID Document Liveness Detection SDK Demo</p> | |
| </div> | |
| </a> | |
| <br/> | |
| <div style="display: flex; justify-content: center; align-items: center;"> | |
| <table style="text-align: center;"> | |
| <tr> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://github.com/MiniAiLive"><img src="https://miniai.live/wp-content/uploads/2024/10/new_git-1-300x67.png" style="height: 50px; margin-right: 5px;" title="GITHUB"/></a></td> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://huggingface.co/MiniAiLive"><img src="https://miniai.live/wp-content/uploads/2024/10/new_hugging-1-300x67.png" style="height: 50px; margin-right: 5px;" title="HuggingFace"/></a></td> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://demo.miniai.live"><img src="https://miniai.live/wp-content/uploads/2024/10/new_gradio-300x67.png" style="height: 50px; margin-right: 5px;" title="Gradio"/></a></td> | |
| </tr> | |
| <tr> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://docs.miniai.live/"><img src="https://miniai.live/wp-content/uploads/2024/10/a-300x70.png" style="height: 50px; margin-right: 5px;" title="Documentation"/></a></td> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://www.youtube.com/@miniailive"><img src="https://miniai.live/wp-content/uploads/2024/10/Untitled-1-300x70.png" style="height: 50px; margin-right: 5px;" title="Youtube"/></a></td> | |
| <td style="text-align: center; vertical-align: middle;"><a href="https://play.google.com/store/apps/dev?id=5831076207730531667"><img src="https://miniai.live/wp-content/uploads/2024/10/googleplay-300x62.png" style="height: 50px; margin-right: 5px;" title="Google Play"/></a></td> | |
| </tr> | |
| </table> | |
| </div> | |
| <br/> | |
| """ | |
| ) | |
| with gr.Tabs(): | |
| with gr.TabItem("ID Document Liveness Detection"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| im_idlive_input = gr.Image(type='filepath', height=300) | |
| gr.Examples( | |
| [ | |
| os.path.join(os.path.dirname(__file__), "images/demo1.jpg"), | |
| ], | |
| inputs=im_idlive_input | |
| ) | |
| btn_f_idlive = gr.Button("Analysis Document", variant='primary') | |
| with gr.Column(): | |
| txt_idlive_output = gr.Textbox(label="API Response (JSON)") | |
| btn_f_idlive.click(check_id_liveness, inputs=im_idlive_input, outputs=txt_idlive_output) | |
| gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiniAiLive%2FID-Document-Liveness-Demo"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FMiniAiLive%2FID-Document-Liveness-Demo&label=VISITORS&labelColor=%2337d67a&countColor=%23ff8a65&style=plastic&labelStyle=none" /></a>') | |
| if __name__ == "__main__": | |
| MiniAIdemo.launch() |