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