dassum commited on
Commit
9f5a1dc
1 Parent(s): b2f457f

Updated from colab

Browse files
Files changed (1) hide show
  1. app.py +4 -17
app.py CHANGED
@@ -1,7 +1,8 @@
1
 
 
2
  from transformers import pipeline
3
  from PIL import Image, ImageDraw
4
- from sentence_transformers import util, SentenceTransformer
5
 
6
  checkpoint = "google/owlvit-base-patch32"
7
  detector = pipeline(model=checkpoint, task="zero-shot-object-detection")
@@ -26,10 +27,10 @@ def get_face_image(im1):
26
  continue
27
  draw = ImageDraw.Draw(im1)
28
  draw.rectangle(box_area, outline="red", width=1)
29
- draw.text((xmin, ymin), f"{label}: {round(score,2)}", fill="blue")
30
  crop_img1 = im1.crop(box_area)
31
  #display(crop_img1)
32
- newsize = (200, 200)
33
  face_img1 = crop_img1.resize(newsize)
34
  #display(face_img1)
35
  return face_img1
@@ -45,17 +46,3 @@ def predict(im1, im2,inp_sim):
45
  else:
46
  return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
47
 
48
- import gradio as gr
49
- description = "An application that can recognize if two faces belong to the same person or not"
50
- title = "Facial Identity Recognition System"
51
-
52
- interface = gr.Interface(fn=predict,
53
- inputs= [gr.Image(type="pil", source="webcam"),
54
- gr.Image(type="pil"),
55
- gr.Slider(0, 1, value=0.8, label="Similarity Percentage", info="Choose betwen 0 and 1")],
56
- outputs= [gr.Number(label="Similarity"),
57
- gr.Textbox(label="Message")]
58
- )
59
-
60
- interface.launch(debug=True)
61
-
 
1
 
2
+ from sentence_transformers import util
3
  from transformers import pipeline
4
  from PIL import Image, ImageDraw
5
+ from sentence_transformers import util,SentenceTransformer
6
 
7
  checkpoint = "google/owlvit-base-patch32"
8
  detector = pipeline(model=checkpoint, task="zero-shot-object-detection")
 
27
  continue
28
  draw = ImageDraw.Draw(im1)
29
  draw.rectangle(box_area, outline="red", width=1)
30
+ #draw.text((xmin, ymin), f"{label}: {round(score,2)}", fill="blue")
31
  crop_img1 = im1.crop(box_area)
32
  #display(crop_img1)
33
+ newsize = (256, 256)
34
  face_img1 = crop_img1.resize(newsize)
35
  #display(face_img1)
36
  return face_img1
 
46
  else:
47
  return sim, "DIFFERENT PEOPLE, DON'T UNLOCK"
48