Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -88,31 +88,48 @@ def receive_image(image):
|
|
88 |
# current_date = now.strftime("%Y-%m-%d")
|
89 |
# csv_file = open(f"{current_date}.csv", "a+", newline="")
|
90 |
|
91 |
-
# csv_writer = csv.writer(csv_file)
|
92 |
-
small_frame = cv2.resize(image, (0, 0), fx=0.25, fy=0.25)
|
93 |
-
rgb_small_frame = small_frame[:, :, ::-1]
|
94 |
-
# emit("result",{"name":"level " +str(cnt),"score":str(len(face_encodings))})
|
95 |
|
96 |
-
face_locations = face_recognition.face_locations(rgb_small_frame)
|
97 |
-
face_encodings = face_recognition.face_encodings(small_frame, face_locations)
|
98 |
-
face_names = []
|
99 |
-
emit("result",{"name":"level2 " +str(cnt),"score":str(len(face_encodings))})
|
100 |
-
cnt = cnt +1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
for face_encoding in face_encodings:
|
102 |
-
# emit("result",{"name":"in for ","score":"34"})
|
103 |
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
104 |
-
name = ""
|
105 |
face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
|
106 |
best_match_index = np.argmin(face_distance)
|
107 |
if matches[best_match_index]:
|
108 |
name = known_faces_names[best_match_index]
|
109 |
-
|
110 |
face_names.append(name)
|
111 |
s = False
|
112 |
break
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
116 |
|
117 |
|
118 |
# # for name in face_names:
|
|
|
88 |
# current_date = now.strftime("%Y-%m-%d")
|
89 |
# csv_file = open(f"{current_date}.csv", "a+", newline="")
|
90 |
|
91 |
+
# # csv_writer = csv.writer(csv_file)
|
92 |
+
# small_frame = cv2.resize(image, (0, 0), fx=0.25, fy=0.25)
|
93 |
+
# rgb_small_frame = small_frame[:, :, ::-1]
|
94 |
+
# # emit("result",{"name":"level " +str(cnt),"score":str(len(face_encodings))})
|
95 |
|
96 |
+
# face_locations = face_recognition.face_locations(rgb_small_frame)
|
97 |
+
# face_encodings = face_recognition.face_encodings(small_frame, face_locations)
|
98 |
+
# face_names = []
|
99 |
+
# emit("result",{"name":"level2 " +str(cnt),"score":str(len(face_encodings))})
|
100 |
+
# cnt = cnt +1
|
101 |
+
# for face_encoding in face_encodings:
|
102 |
+
# # emit("result",{"name":"in for ","score":"34"})
|
103 |
+
# matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
104 |
+
# name = ""
|
105 |
+
# face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
|
106 |
+
# best_match_index = np.argmin(face_distance)
|
107 |
+
# if matches[best_match_index]:
|
108 |
+
# name = known_faces_names[best_match_index]
|
109 |
+
|
110 |
+
# face_names.append(name)
|
111 |
+
# s = False
|
112 |
+
# break
|
113 |
+
|
114 |
+
# emit("result",{"name":str(name),"score":"myScore"})
|
115 |
+
|
116 |
+
name = "" # Initialize name with a default value
|
117 |
+
|
118 |
for face_encoding in face_encodings:
|
|
|
119 |
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
|
|
120 |
face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
|
121 |
best_match_index = np.argmin(face_distance)
|
122 |
if matches[best_match_index]:
|
123 |
name = known_faces_names[best_match_index]
|
124 |
+
|
125 |
face_names.append(name)
|
126 |
s = False
|
127 |
break
|
128 |
+
|
129 |
+
cnt = cnt + 1
|
130 |
+
|
131 |
+
emit("result", {"name": str(name), "score": "myScore"})
|
132 |
+
emit("result", {"name": "level1", "score": "34"})
|
133 |
|
134 |
|
135 |
# # for name in face_names:
|