Spaces:
Runtime error
Runtime error
| import sys | |
| import os | |
| import io | |
| import base64 | |
| import json | |
| import gradio as gr | |
| import requests | |
| def face_recognition_on_file(file1, file2): | |
| url = "http://93.127.215.33:8080/face_recognition" | |
| try: | |
| files = {'file1': open(file1, 'rb'), 'file2': open(file2, 'rb')} | |
| r = requests.post(url=url, files=files) | |
| r.raise_for_status() # Raise an exception for bad status codes | |
| except requests.RequestException as e: | |
| raise gr.Error(f"Error occurred: {str(e)}") | |
| except IOError: | |
| raise gr.Error("Please select valid image files!") | |
| try: | |
| response = r.json() | |
| print(response) | |
| return response | |
| except json.JSONDecodeError: | |
| raise gr.Error("Invalid response from server") | |
| def liveness_detection_on_file(file): | |
| url = "http://93.127.215.33:8080/check_liveness" | |
| try: | |
| files = {'file': open(file, 'rb')} | |
| r = requests.post(url=url, files=files) | |
| r.raise_for_status() # Raise an exception for bad status codes | |
| except requests.RequestException as e: | |
| raise gr.Error(f"Error occurred: {str(e)}") | |
| try: | |
| response = r.json() | |
| print(response) | |
| return response | |
| except json.JSONDecodeError: | |
| raise gr.Error("Invalid response from server") | |
| with gr.Blocks() as demo: | |
| gr.Markdown( | |
| """ | |
| <a href="https://faceplugin.com" style="display: flex; align-items: center;"> | |
| <img src="https://faceplugin.com/wp-content/uploads/2024/02/Square-png-file_2-1.png" style="width: 8%; margin-right: 15px;"/> | |
| <div> | |
| <p style="font-size: 24px; font-weight: bold; margin: 0;">FacePlugIn Ltd</p> | |
| </div> | |
| </a> | |
| ## Company Overview | |
| Faceplugin offers cutting-edge face recognition SDK, liveness detection SDK, and ID card recognition SDK designed for seamless ID verification and biometric authentication. Our fully on-premise SDK solutions ensure data security and compliance with privacy regulations. Contact us today to learn more about how our biometric authentication and ID verification solutions can elevate your business | |
| <h2>List of our Products</h2> | |
| * **[FaceRecognition-LivenessDetection-Android](https://github.com/Faceplugin-ltd/FaceRecognition-Android)** | |
| * **[FaceRecognition-LivenessDetection-iOS](https://github.com/Faceplugin-ltd/FaceRecognition-iOS)** | |
| * **[FaceRecognition-LivenessDetection-Javascript](https://github.com/Faceplugin-ltd/FaceRecognition-LivenessDetection-Javascript)** | |
| * **[FaceLivenessDetection-linux](https://github.com/Faceplugin-ltd/FaceLivenessDetection-Linux)** | |
| * **[Completely Free Face Recognition SDK](https://github.com/Faceplugin-ltd/Face-Recognition)** | |
| * **[Completely Free Document Liveness SDK](https://github.com/Faceplugin-ltd/ID-Document-Liveness-Detection)** | |
| ## Contact | |
| <div style="display: flex; align-items: center;"> | |
| <a target="_blank" href="mailto:info@faceplugin.com"><img src="https://img.shields.io/badge/email-info@faceplugin.com-blue.svg?logo=gmail " alt="faceplugin.com"></a> | |
| <a target="_blank" href="https://t.me/faceplugin"><img src="https://img.shields.io/badge/telegram-@faceplugin-blue.svg?logo=telegram " alt="faceplugin.com"></a> | |
| <a target="_blank" href="https://wa.me/+14422295661"><img src="https://img.shields.io/badge/whatsapp-faceplugin-blue.svg?logo=whatsapp " alt="faceplugin.com"> | |
| </div> | |
| """ | |
| ) | |
| with gr.TabItem("Face Liveness Detection"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| app_input = gr.Image(type='filepath') | |
| gr.Examples(['images/4.jpg', 'images/1.png', 'images/2.png', 'images/3.png'], | |
| inputs=app_input) | |
| start_button = gr.Button("Run") | |
| with gr.Column(): | |
| app_output = [gr.JSON()] | |
| start_button.click(liveness_detection_on_file, inputs=app_input, outputs=app_output) | |
| gr.HTML('<a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FFacePlugin-Ltd%2FFacePlugin-Face-Recognition-SDK"><img src="https://api.visitorbadge.io/api/combined?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FFacePlugin-Ltd%2FFacePlugin-Face-Recognition-SDK&labelColor=%23697689&countColor=%2337d67a&style=flat&labelStyle=upper" /></a>') | |
| demo.queue().launch(share=True) | |