Spaces:
Runtime error
Runtime error
import gradio as gr | |
from sentence_transformers import SentenceTransformer,util | |
model = SentenceTransformer("sentence-transformers/clip-ViT-L-14") | |
def predict(im1, im2): | |
sim=util.cos_sim(model.encode(im1),model.encode(im2)).item() | |
if sim > 0.8: | |
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")], | |
title='Face Verification', | |
description='Use your phone camera || Take two pictures || Compare their similarity' | |
) | |
interface.launch() | |