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( """

FacePlugIn Ltd

## Company Overview FacePlugin Ltd is a pioneering company at the forefront of innovative solutions in the realm of facial recognition technology and computer vision. Established with a commitment to revolutionize security and authentication processes, FacePlugin specializes in cutting-edge solutions including face liveness detection, ID card recognition, face recognition, biometric authentication, and e-KYC (Electronic Know Your Customer) solutions.

List of our Products

* **[FaceRecognition-LivenessDetection-Android](https://github.com/Faceplugin-ltd/FaceRecognition-LivenessDetection-Android)** * **[FaceRecognition-LivenessDetection-iOS](https://github.com/Faceplugin-ltd/FaceRecognition-LivenessDetection-iOS)** * **[FaceRecognition-LivenessDetection-Javascript](https://github.com/Faceplugin-ltd/FaceRecognition-LivenessDetection-Javascript)** * **[FaceLivenessDetection-Docker](https://github.com/Faceplugin-ltd/FaceLivenessDetection-Docker)** ## Contact
faceplugin.com   faceplugin.com   faceplugin.com
""" ) with gr.TabItem("Face Recognition"): with gr.Row(): with gr.Column(): first_input = gr.Image(type='filepath') gr.Examples(['images/rec_7.jpg', 'images/rec_1.jpg', 'images/9.png', 'images/rec_3.jpg'], inputs=first_input) start_button = gr.Button("Run") with gr.Column(): second_input = gr.Image(type='filepath') gr.Examples(['images/rec_8.jpg', 'images/rec_2.jpg', 'images/10.jpg', 'images/rec_4.jpg'], inputs=second_input) with gr.Column(): app_output = [gr.JSON()] start_button.click(face_recognition_on_file, inputs=[first_input, second_input], outputs=app_output) 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('') demo.queue().launch(share=True)