|
import gradio as gr |
|
import matplotlib.pyplot as plt |
|
from sentence_transformers import SentenceTransformer |
|
|
|
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" |
|
|
|
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) |