Spaces:
Runtime error
Runtime error
Shafeek Saleem commited on
Commit ·
e87299f
1
Parent(s): f36346b
added face encodings pagejj
Browse files52 unmodified lines5354555656575859606162636364656667686667697071727352 unmodified lines cols[i].image(os.path.join(img_dir, img), use_column_width=True) cols[i].write(face_name) st.subheader("Lets create face encodings for the known-faces.") face_encodings_dict = {} # face_encodings_dict = {} if st.button("Create Face Encodings"): my_bar = st.progress(0, text="Generating face encodings...") if len(images) > 0: for i, img in enumerate(images): face_image = face_recognition.load_image_file(os.path.join(img_dir, img)) my_face_encoding = face_recognition.face_encodings(face_image) my_bar.progress(int((i + 1) / len(images) * 100), text="Generating face encodings...") face_encodings_dict[img.split("_")[1]] = face_recognition.face_encodings(face_image).tolist() with open(os.path.join(".sessions", get_login()["username"], img.split("_")[1]+".npy"), 'wb') as f: np.save(f, my_face_encoding) # face_encodings_dict[img.split("_")[1]] = my_face_encoding.tolist() my_bar.progress(100, text="Successfully encoded all the known faces!") st.success("Face encoding completed successfully!") with open(os.path.join(".sessions", get_login()["username"], "face_encodings.json"), "w") as write_file: json.dump(face_encodings_dict, write_file, indent=4) # with open(os.path.join(".sessions", get_login()["username"], "face_encodings.json"), "w") as write_file: # json.dump(face_encodings_dict, write_file, indent=4) complete_level(LEVEL) else: my_bar.empty()pages/3_Face Encodings.py+7-4