Saiteja commited on
Commit
a1e78bf
1 Parent(s): 7bbc93d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +23 -0
main.py CHANGED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import matplotlib.pyplot as plt
2
+
3
+ import gradio as gr
4
+
5
+ def predict(im1, im2):
6
+ # ANSWER HERE
7
+ embeddings = model.encode([im1, im2])
8
+ sim = cosine_similarity(embeddings[0].reshape(1, -1), embeddings[1].reshape(1, -1))[0][0]
9
+ if sim > 0.89:
10
+ return sim, "SAME PERSON, UNLOCK PHONE"
11
+ else:
12
+ return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
13
+
14
+
15
+
16
+ interface = gr.Interface(fn=predict,
17
+ inputs= [gr.Image(type="pil", source="webcam"),
18
+ gr.Image(type="pil", source="webcam")],
19
+ outputs= [gr.Number(label="Similarity"),
20
+ gr.Textbox(label="Message")]
21
+ )
22
+
23
+ interface.launch(debug=True)