Spaces:
Running
Running
Updated from colab
Browse files- app.py +25 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from sentence_transformers import util,SentenceTransformer
|
3 |
+
model = SentenceTransformer('clip-ViT-L-14')
|
4 |
+
|
5 |
+
def predict(im1, im2):
|
6 |
+
img_emb = model.encode([im1, im2])
|
7 |
+
sim = util.cos_sim(img_emb[0], img_emb[1])
|
8 |
+
if sim > 0.82:
|
9 |
+
return sim, "SAME PERSON, UNLOCK PHONE"
|
10 |
+
else:
|
11 |
+
return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
|
12 |
+
|
13 |
+
import gradio as gr
|
14 |
+
description = "An application that can recognize if two faces belong to the same person or not"
|
15 |
+
title = "Facial Identity Recognition System"
|
16 |
+
|
17 |
+
interface = gr.Interface(fn=predict,
|
18 |
+
inputs= [gr.Image(type="pil", source="webcam"),
|
19 |
+
gr.Image(type="pil", source="webcam")],
|
20 |
+
outputs= [gr.Number(label="Similarity"),
|
21 |
+
gr.Textbox(label="Message")]
|
22 |
+
)
|
23 |
+
|
24 |
+
interface.launch(debug=True)
|
25 |
+
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
sentence-transformers
|