nikshep01 commited on
Commit
b7a271e
1 Parent(s): 1be28be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -4,9 +4,18 @@ import face_recognition
4
  import cv2
5
  import numpy as np
6
  import os
 
7
  from datetime import datetime
8
  import CSV
9
 
 
 
 
 
 
 
 
 
10
  st.title("AIMLJan24 - Face Recognition")
11
 
12
  # Load images for face recognition
@@ -36,13 +45,14 @@ encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
36
  # camera to take photo of user in question
37
  file_name = st.camera_input("Upload image")
38
 
39
- def add_attendance(names):
40
- current_datetime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
41
- print('Date',current_datetime)
42
- with open(f'Attendance/Attendance-{current_datetime}.csv', 'a') as f:
43
- f.write('Name,Time\n') # Write header if file is newly created
44
- for name in names:
45
- f.write(f'{name},{current_datetime}\n')
 
46
 
47
 
48
  if file_name is not None:
 
4
  import cv2
5
  import numpy as np
6
  import os
7
+ import sqlite3
8
  from datetime import datetime
9
  import CSV
10
 
11
+ conn = sqlite3.connect('attendance.db')
12
+ c = conn.cursor()
13
+
14
+ # Create a table for storing attendance if it doesn't exist
15
+ c.execute('''CREATE TABLE IF NOT EXISTS attendance
16
+ (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, time TEXT)''')
17
+
18
+
19
  st.title("AIMLJan24 - Face Recognition")
20
 
21
  # Load images for face recognition
 
45
  # camera to take photo of user in question
46
  file_name = st.camera_input("Upload image")
47
 
48
+ def add_attendance(name):
49
+ username = name
50
+
51
+ print(current_datetime)
52
+
53
+ # Insert data into the attendance table
54
+ c.execute("INSERT INTO attendance (name, time) VALUES (?, ?)", (username, current_datetime))
55
+ conn.commit()
56
 
57
 
58
  if file_name is not None: