FacePass / app.py
909ahmed's picture
fafdasdf
be9fb11
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()