File size: 1,573 Bytes
be9fb11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from yolo.yoloFace import YOLO_FACE
from vgg.vgg_face import MODEL_FACE
from database.retriever import BruteForceStore
import cv2

# Initialize the database
DB = BruteForceStore()

def pipeline(img):
    images = YOLO_FACE(img)
    for patch in images:
        embeddings = MODEL_FACE(patch)
        if DB(embeddings):
            return "Welcome!"
    return "Unauthorised"

# Define a Gradio interface
def process_image(image):
    if image is None:
        return "Please upload an image."
    result = pipeline(image)
    return result

# Gradio App
with gr.Blocks() as demo:
    gr.Markdown("""
    <div style="background: url('/home/asad/temp/app/FacePass/logo.png') no-repeat center center fixed; background-size: cover; height: 100%; padding: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center;">
        <h1 style="text-align: center; color: white;">
            Face Verification App
        </h1>
        <h3 style="text-align: center; color: lightgrey;">
            Upload your photo and let the app verify your identity!
        </h3>
    </div>
    """)

    with gr.Row():
        with gr.Column(scale=1):
            image_input = gr.Image(type="numpy", label="Upload Your Image")
        with gr.Column(scale=1):
            output_text = gr.Textbox(label="Verification Result", interactive=False)

    with gr.Row():
        submit_button = gr.Button("Verify")
        submit_button.click(process_image, inputs=[image_input], outputs=[output_text])

if __name__ == "__main__":
    demo.launch()