File size: 2,785 Bytes
901e379
 
0e1e06d
901e379
 
 
 
 
 
 
 
 
 
 
 
 
5143658
0e1e06d
a86b2f7
901e379
 
 
 
 
0e1e06d
901e379
 
 
5143658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901e379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5143658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901e379
5143658
901e379
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import sys
sys.path.append('.')
sys.path.append('./face_recognition')
import os
import io
import cv2
import base64
import json
import gradio as gr
import requests
import numpy as np
from io import BytesIO
import configparser
import numpy as np
from PIL import Image

# from face_recognition.match import match_1_1
# from face_recognition1.run import match_image


def face_recognition_on_file(file1, file2):
    img1 = cv2.imread(file1)
    img2 = cv2.imread(file2)

    response = match_1_1(img1, img2)

    return response

def liveness_detection_on_file(file1, file2):
    img1 = cv2.imread(file1)
    img2 = cv2.imread(file2)

    response = match_1_1(img1, img2)

    return response

def mrz_recognition_on_file(file1, file2):
    img1 = cv2.imread(file1)
    img2 = cv2.imread(file2)

    response = match_1_1(img1, img2)

    return response

with gr.Blocks() as demo:
    gr.Markdown(
        """
    # FacePlugin Online Demo

    """
    )

    with gr.TabItem("Face Recognition"):
        with gr.Row():
            with gr.Column():
                first_input = gr.Image(type='filepath')
                gr.Examples(['images/rec_5.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_6.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)
    with gr.TabItem("ID Document Recognition"):
        with gr.Row():
            with gr.Column():
                app_input = gr.Image(type='pil')
                gr.Examples(['images/mrz_1.jpg', 'images/mrz_2.png', 'images/mrz_3.jpeg', 'images/mrz_4.jpg'],
                            inputs=app_input)
                start_button = gr.Button("Run")
            with gr.Column():
                app_output = [gr.JSON()]

        start_button.click(mrz_recognition_on_file, inputs=app_input, outputs=app_output)
demo.queue().launch(share=True)