import matplotlib.pyplot as plt from sklearn.metrics.pairwise import cosine_similarity from sentence_transformers import SentenceTransformer, util model = SentenceTransformer("sentence-transformers/clip-ViT-L-14") def predict(im1, im2): emb1 = model.encode(im1) emb2 = model.encode(im2) sim = util.cos_sim(emb1, emb2) if sim > 0.80: return sim, "SAME PERSON, UNLOCK PHONE" else: return sim, "DIFFERENT PEOPLE, DON'T UNLOCK" import gradio as gr 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()