File size: 932 Bytes
4269e73 6988e02 4269e73 6988e02 4269e73 b67ce9b 4269e73 |
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 |
import gradio as gr
import matplotlib.pyplot as plt
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
def predict(im1, im2):
model = SentenceTransformer('sentence-transformers/clip-ViT-B-16')
emb = model.encode([im1, im2])
sim = cosine_similarity(emb)[0][1]
if sim > .90:
return sim, "SAME PERSON, UNLOCK PHONE"
else:
return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
description = "A simple vision app that 'unlocks' a phone if two faces are similar."
title = "Simple Face Id"
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) |