Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,15 +35,12 @@ encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
|
| 35 |
# camera to take photo of user in question
|
| 36 |
file_name = st.camera_input("Upload image")
|
| 37 |
|
| 38 |
-
def add_attendance(
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
with open(f'Attendance/Attendance-{datetoday}.csv', 'a') as f:
|
| 45 |
-
f.write(f'\n{username},{aadhaar},{current_datetime}')
|
| 46 |
-
|
| 47 |
|
| 48 |
|
| 49 |
if file_name is not None:
|
|
@@ -92,5 +89,7 @@ if file_name is not None:
|
|
| 92 |
st.write("Recognized Names:")
|
| 93 |
for i, name in enumerate(recognized_names):
|
| 94 |
st.write(f"Face {i+1}: {name}")
|
|
|
|
|
|
|
| 95 |
else:
|
| 96 |
st.warning("No faces detected in the image. Face recognition failed.")
|
|
|
|
| 35 |
# camera to take photo of user in question
|
| 36 |
file_name = st.camera_input("Upload image")
|
| 37 |
|
| 38 |
+
def add_attendance(names):
|
| 39 |
+
current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 40 |
+
with open(f'Attendance/Attendance-{current_datetime}.csv', 'a') as f:
|
| 41 |
+
f.write('Name,Time\n') # Write header if file is newly created
|
| 42 |
+
for name in names:
|
| 43 |
+
f.write(f'{name},{current_datetime}\n')
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
if file_name is not None:
|
|
|
|
| 89 |
st.write("Recognized Names:")
|
| 90 |
for i, name in enumerate(recognized_names):
|
| 91 |
st.write(f"Face {i+1}: {name}")
|
| 92 |
+
if len(recognized_names) > 0:
|
| 93 |
+
add_attendance(recognized_names)
|
| 94 |
else:
|
| 95 |
st.warning("No faces detected in the image. Face recognition failed.")
|