MHRDYN7 commited on
Commit
be8bae6
1 Parent(s): 65ce4c4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import face_recognition
2
+ import cv2
3
+ import joblib
4
+ import gradio as gr
5
+
6
+ encodings = joblib.load('/content/saved_encodings')
7
+ names = joblib.load('/content/saved_names')
8
+
9
+ def FaceRec(img):
10
+ img_enc = face_recognition.face_encodings(img)[0]
11
+ results = face_recognition.compare_faces((encodings), img_enc)
12
+ for i in range(len(results)):
13
+ if results[i]:
14
+ name = names[i]
15
+ (top, right, bottom, left) = face_recognition.face_locations(img)[0]
16
+ cv2.rectangle(img, (left, top), (right, bottom), (0, 0, 255), 2)
17
+ cv2.putText(img, name, (left+2, bottom+20), cv2.FONT_HERSHEY_PLAIN, 1, (255, 255, 255), 1)
18
+
19
+ return img
20
+
21
+
22
+
23
+ interface = gr.Interface(FaceRec, gr.inputs.Image(shape=(200,200)), "image")
24
+
25
+ interface.launch(debug = True, inline = False)