Spaces:
Runtime error
Runtime error
Shafeek Saleem
commited on
Commit
·
eceda24
1
Parent(s):
3acfa00
added face encodings pagejj
Browse files
pages/3_Face Encodings.py
CHANGED
|
@@ -45,6 +45,8 @@ def step3_page():
|
|
| 45 |
)
|
| 46 |
|
| 47 |
img_dir = os.path.join(".sessions", get_login()["username"], "known_faces")
|
|
|
|
|
|
|
| 48 |
images = os.listdir(img_dir)
|
| 49 |
if len(images) > 0:
|
| 50 |
st.subheader("Let's see your saved faces in your known-face database.")
|
|
@@ -62,7 +64,7 @@ def step3_page():
|
|
| 62 |
face_image = face_recognition.load_image_file(os.path.join(img_dir, img))
|
| 63 |
my_face_encoding = face_recognition.face_encodings(face_image)
|
| 64 |
my_bar.progress(int((i + 1) / len(images) * 100), text="Generating face encodings...")
|
| 65 |
-
np.save(os.path.join(
|
| 66 |
# face_encodings_dict[img.split("_")[1]] = my_face_encoding.tolist()
|
| 67 |
my_bar.progress(100, text="Successfully encoded all the known faces!")
|
| 68 |
st.success("Face encoding completed successfully!")
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
img_dir = os.path.join(".sessions", get_login()["username"], "known_faces")
|
| 48 |
+
face_encodings_dir = os.path.join(".sessions", get_login()["username"], "face_encodings")
|
| 49 |
+
os.makedirs(face_encodings_dir, exist_ok=True)
|
| 50 |
images = os.listdir(img_dir)
|
| 51 |
if len(images) > 0:
|
| 52 |
st.subheader("Let's see your saved faces in your known-face database.")
|
|
|
|
| 64 |
face_image = face_recognition.load_image_file(os.path.join(img_dir, img))
|
| 65 |
my_face_encoding = face_recognition.face_encodings(face_image)
|
| 66 |
my_bar.progress(int((i + 1) / len(images) * 100), text="Generating face encodings...")
|
| 67 |
+
np.save(os.path.join(face_encodings_dir, img.split("_")[1]+".npy"), my_face_encoding)
|
| 68 |
# face_encodings_dict[img.split("_")[1]] = my_face_encoding.tolist()
|
| 69 |
my_bar.progress(100, text="Successfully encoded all the known faces!")
|
| 70 |
st.success("Face encoding completed successfully!")
|