FACE-ID / main.py
Saiteja's picture
Update main.py
a1e78bf
raw
history blame
719 Bytes
import matplotlib.pyplot as plt
import gradio as gr
def predict(im1, im2):
# ANSWER HERE
embeddings = model.encode([im1, im2])
sim = cosine_similarity(embeddings[0].reshape(1, -1), embeddings[1].reshape(1, -1))[0][0]
if sim > 0.89:
return sim, "SAME PERSON, UNLOCK PHONE"
else:
return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
interface = gr.Interface(fn=predict,
inputs= [gr.Image(type="pil", source="webcam"),
gr.Image(type="pil", source="webcam")],
outputs= [gr.Number(label="Similarity"),
gr.Textbox(label="Message")]
)
interface.launch(debug=True)