Vikas01 commited on
Commit
7270c05
1 Parent(s): 553b504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -50
app.py CHANGED
@@ -63,73 +63,73 @@ def receive_image(image):
63
  # index = np.argmax(prediction)
64
  # class_name = class_names[index]
65
  # confidence_score = prediction[0][index]
66
- # emit("result",{"name":str(class_name),"score":str(confidence_score)})
67
  # #######################
68
 
69
 
70
 
71
 
72
- # @app.route('/at')
73
- # def attend():
74
- # # Face recognition variables
75
- known_faces_names = ["Sarwan Sir", "Vikas","Lalit","Jasmeen","Anita Ma'am"]
76
- known_face_encodings = []
77
 
78
- # Load known face encodings
79
- sir_image = face_recognition.load_image_file("photos/sir.jpeg")
80
- sir_encoding = face_recognition.face_encodings(sir_image)[0]
81
 
82
- vikas_image = face_recognition.load_image_file("photos/vikas.jpg")
83
- vikas_encoding = face_recognition.face_encodings(vikas_image)[0]
84
 
85
- lalit_image = face_recognition.load_image_file("photos/lalit.jpg")
86
- lalit_encoding = face_recognition.face_encodings(lalit_image)[0]
87
 
88
- jasmine_image = face_recognition.load_image_file("photos/jasmine.jpg")
89
- jasmine_encoding = face_recognition.face_encodings(jasmine_image)[0]
90
 
91
- maam_image = face_recognition.load_image_file("photos/maam.png")
92
- maam_encoding = face_recognition.face_encodings(maam_image)[0]
93
 
94
- known_face_encodings = [sir_encoding, vikas_encoding,lalit_encoding,jasmine_encoding,maam_encoding]
95
 
96
- students = known_faces_names.copy()
97
 
98
- face_locations = []
99
- face_encodings = []
100
- face_names = []
101
 
102
- # now = datetime.now()
103
- # current_date = now.strftime("%Y-%m-%d")
104
- # csv_file = open(f"{current_date}.csv", "a+", newline="")
105
 
106
- # csv_writer = csv.writer(csv_file)
107
- small_frame = cv2.resize(image, (0, 0), fx=0.25, fy=0.25)
108
- rgb_small_frame = small_frame[:, :, ::-1]
109
 
110
- face_locations = face_recognition.face_locations(rgb_small_frame)
111
- face_encodings = face_recognition.face_encodings(small_frame, face_locations)
112
- face_names = []
113
-
114
- for face_encoding in face_encodings:
115
- matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
116
- name = ""
117
- face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
118
- best_match_index = np.argmin(face_distance)
119
- if matches[best_match_index]:
120
- name = known_faces_names[best_match_index]
121
-
122
- face_names.append(name)
123
- emit("result",{"name":str(name),"score":"myScore"})
124
 
125
- # for name in face_names:
126
- # if name in known_faces_names and name in students and name not in existing_names:
127
- # students.remove(name)
128
- # print(students)
129
- # print(f"Attendance recorded for {name}")
130
- # current_time = now.strftime("%H-%M-%S")
131
- # csv_writer.writerow([name, current_time, "Present"])
132
- # existing_names.add(name) # Add the name to the set of existing names
133
 
134
  @app.route ("/")
135
  def home():
 
63
  # index = np.argmax(prediction)
64
  # class_name = class_names[index]
65
  # confidence_score = prediction[0][index]
66
+ emit("result",{"name":"mrmr","score":"34"})
67
  # #######################
68
 
69
 
70
 
71
 
72
+ # # @app.route('/at')
73
+ # # def attend():
74
+ # # # Face recognition variables
75
+ # known_faces_names = ["Sarwan Sir", "Vikas","Lalit","Jasmeen","Anita Ma'am"]
76
+ # known_face_encodings = []
77
 
78
+ # # Load known face encodings
79
+ # sir_image = face_recognition.load_image_file("photos/sir.jpeg")
80
+ # sir_encoding = face_recognition.face_encodings(sir_image)[0]
81
 
82
+ # vikas_image = face_recognition.load_image_file("photos/vikas.jpg")
83
+ # vikas_encoding = face_recognition.face_encodings(vikas_image)[0]
84
 
85
+ # lalit_image = face_recognition.load_image_file("photos/lalit.jpg")
86
+ # lalit_encoding = face_recognition.face_encodings(lalit_image)[0]
87
 
88
+ # jasmine_image = face_recognition.load_image_file("photos/jasmine.jpg")
89
+ # jasmine_encoding = face_recognition.face_encodings(jasmine_image)[0]
90
 
91
+ # maam_image = face_recognition.load_image_file("photos/maam.png")
92
+ # maam_encoding = face_recognition.face_encodings(maam_image)[0]
93
 
94
+ # known_face_encodings = [sir_encoding, vikas_encoding,lalit_encoding,jasmine_encoding,maam_encoding]
95
 
96
+ # students = known_faces_names.copy()
97
 
98
+ # face_locations = []
99
+ # face_encodings = []
100
+ # face_names = []
101
 
102
+ # # now = datetime.now()
103
+ # # current_date = now.strftime("%Y-%m-%d")
104
+ # # csv_file = open(f"{current_date}.csv", "a+", newline="")
105
 
106
+ # # csv_writer = csv.writer(csv_file)
107
+ # small_frame = cv2.resize(image, (0, 0), fx=0.25, fy=0.25)
108
+ # rgb_small_frame = small_frame[:, :, ::-1]
109
 
110
+ # face_locations = face_recognition.face_locations(rgb_small_frame)
111
+ # face_encodings = face_recognition.face_encodings(small_frame, face_locations)
112
+ # face_names = []
113
+
114
+ # for face_encoding in face_encodings:
115
+ # matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
116
+ # name = ""
117
+ # face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
118
+ # best_match_index = np.argmin(face_distance)
119
+ # if matches[best_match_index]:
120
+ # name = known_faces_names[best_match_index]
121
+
122
+ # face_names.append(name)
123
+ # emit("result",{"name":str(name),"score":"myScore"})
124
 
125
+ # # for name in face_names:
126
+ # # if name in known_faces_names and name in students and name not in existing_names:
127
+ # # students.remove(name)
128
+ # # print(students)
129
+ # # print(f"Attendance recorded for {name}")
130
+ # # current_time = now.strftime("%H-%M-%S")
131
+ # # csv_writer.writerow([name, current_time, "Present"])
132
+ # # existing_names.add(name) # Add the name to the set of existing names
133
 
134
  @app.route ("/")
135
  def home():