Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -79,58 +79,14 @@ def attend():
|
|
79 |
|
80 |
def run_face_recognition():
|
81 |
bytes_data=None
|
|
|
82 |
img_file_buffer=st.camera_input("Take a picture")
|
83 |
if img_file_buffer is not None:
|
84 |
-
|
85 |
-
st.
|
86 |
-
|
87 |
-
st.image(img_file_buffer)
|
88 |
-
|
89 |
-
# s = True
|
90 |
-
|
91 |
-
# existing_names = set(row[0] for row in csv.reader(csv_file)) # Collect existing names from the CSV file
|
92 |
-
|
93 |
-
|
94 |
-
# while s:
|
95 |
-
# _, frame = img_file_buffer.read()
|
96 |
-
# small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
|
97 |
-
# rgb_small_frame = small_frame[:, :, ::-1]
|
98 |
-
|
99 |
-
# face_locations = face_recognition.face_locations(rgb_small_frame)
|
100 |
-
# face_encodings = face_recognition.face_encodings(small_frame, face_locations)
|
101 |
-
# face_names = []
|
102 |
-
|
103 |
-
# for face_encoding in face_encodings:
|
104 |
-
# matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
105 |
-
# name = ""
|
106 |
-
# face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
|
107 |
-
# best_match_index = np.argmin(face_distance)
|
108 |
-
# if matches[best_match_index]:
|
109 |
-
# name = known_faces_names[best_match_index]
|
110 |
-
|
111 |
-
# face_names.append(name)
|
112 |
-
|
113 |
-
|
114 |
-
# for name in face_names:
|
115 |
-
# if name in known_faces_names and name in students and name not in existing_names:
|
116 |
-
# students.remove(name)
|
117 |
-
# print(students)
|
118 |
-
# print(f"Attendance recorded for {name}")
|
119 |
-
# current_time = now.strftime("%H-%M-%S")
|
120 |
-
# csv_writer.writerow([name, current_time, "Present"])
|
121 |
-
# existing_names.add(name) # Add the name to the set of existing names
|
122 |
-
|
123 |
-
# s = False # Set s to False to exit the loop after recording attendance
|
124 |
-
# break # Break the loop once attendance has been recorded for a name
|
125 |
-
|
126 |
-
# cv2.imshow("Attendance System", frame)
|
127 |
-
# if cv2.waitKey(1) & 0xFF == ord('q'):
|
128 |
-
# break
|
129 |
if bytes_data is None:
|
130 |
st.stop()
|
131 |
-
# video_capture.release()
|
132 |
-
# cv2.destroyAllWindows()
|
133 |
-
csv_file.close()
|
134 |
|
135 |
# Call the function to run face recognition
|
136 |
run_face_recognition()
|
|
|
79 |
|
80 |
def run_face_recognition():
|
81 |
bytes_data=None
|
82 |
+
|
83 |
img_file_buffer=st.camera_input("Take a picture")
|
84 |
if img_file_buffer is not None:
|
85 |
+
test_image=Image.open(img_file_buffer)
|
86 |
+
st.image(test_image)
|
87 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
if bytes_data is None:
|
89 |
st.stop()
|
|
|
|
|
|
|
90 |
|
91 |
# Call the function to run face recognition
|
92 |
run_face_recognition()
|