dassum's picture
Update app.py
95286fc
from sentence_transformers import util, SentenceTransformer
model = SentenceTransformer('clip-ViT-L-14')
def predict(im1, im2):
img_emb = model.encode([im1, im2])
sim = util.cos_sim(img_emb[0], img_emb[1])
if sim > 0.82:
return sim, "SAME PERSON, UNLOCK PHONE"
else:
return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
import gradio as gr
description = "An application that can recognize if two faces belong to the same person or not"
title = "Facial Identity Recognition System"
interface = gr.Interface(fn=predict,
inputs= [gr.Image(type="pil", source="webcam"),
gr.Image(shape=(200, 200))],
outputs= [gr.Number(label="Similarity"),
gr.Textbox(label="Message")]
)
interface.launch(debug=True)