Spaces:
Build error
Build error
| from sentence_transformers import SentenceTransformer | |
| from sklearn.metrics.pairwise import cosine_similarity | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import gradio as gr | |
| model = SentenceTransformer('clip-ViT-L-14') | |
| def predict(im1, im2): | |
| sim = cosine_similarity(model.encode(im1).reshape(1,-1), model.encode(im2).reshape(1,-1)) | |
| 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")] | |
| ) | |
| interface.launch(debug=True) | |