Spaces:
Running
Running
File size: 984 Bytes
6b49d7b a74b809 6b49d7b a74b809 6b49d7b a74b809 6b49d7b a74b809 6b49d7b 0c3b034 6b49d7b |
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 |
from sentence_transformers import util,SentenceTransformer
model = SentenceTransformer('clip-ViT-L-14')
def predict(im1, im2,inp_sim):
img_emb = model.encode([im1, im2])
sim = util.cos_sim(img_emb[0], img_emb[1])
if sim > inp_sim:
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(type="pil"),
gr.Slider(0, 1, value=0.8, label="Similarity Percentage", info="Choose betwen 0 and 1")],
outputs= [gr.Number(label="Similarity"),
gr.Textbox(label="Message")]
)
interface.launch(debug=True)
|