dassum commited on
Commit
a74b809
1 Parent(s): 95286fc

added slider

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,11 +1,11 @@
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"
@@ -16,7 +16,8 @@ title = "Facial Identity Recognition System"
16
 
17
  interface = gr.Interface(fn=predict,
18
  inputs= [gr.Image(type="pil", source="webcam"),
19
- gr.Image(shape=(200, 200))],
 
20
  outputs= [gr.Number(label="Similarity"),
21
  gr.Textbox(label="Message")]
22
  )
 
1
 
2
+ from sentence_transformers import util,SentenceTransformer
3
  model = SentenceTransformer('clip-ViT-L-14')
4
 
5
+ def predict(im1, im2,inp_sim):
6
  img_emb = model.encode([im1, im2])
7
  sim = util.cos_sim(img_emb[0], img_emb[1])
8
+ if sim > inp_sim:
9
  return sim, "SAME PERSON, UNLOCK PHONE"
10
  else:
11
  return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
 
16
 
17
  interface = gr.Interface(fn=predict,
18
  inputs= [gr.Image(type="pil", source="webcam"),
19
+ gr.Image(type="pil"),
20
+ gr.Slider(0, 1, value=0.8, label="Similarity Percentage", info="Choose betwen 0 and 1")],
21
  outputs= [gr.Number(label="Similarity"),
22
  gr.Textbox(label="Message")]
23
  )