Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -133,95 +133,95 @@ def snap(image,video):
|
|
133 |
return [image,video]
|
134 |
|
135 |
|
136 |
-
@app.route('/at')
|
137 |
-
def attend():
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
|
146 |
-
|
147 |
-
|
148 |
|
149 |
-
|
150 |
-
|
151 |
|
152 |
-
|
153 |
-
|
154 |
|
155 |
-
|
156 |
-
|
157 |
|
158 |
-
|
159 |
|
160 |
-
|
161 |
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
|
198 |
-
|
199 |
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
|
224 |
-
|
225 |
|
226 |
def gradio_interface():
|
227 |
demo = gr.Interface(
|
@@ -232,7 +232,7 @@ def gradio_interface():
|
|
232 |
return demo
|
233 |
|
234 |
|
235 |
-
@app.route('/
|
236 |
def gradio():
|
237 |
interface = gradio_interface()
|
238 |
return interface.launch()
|
|
|
133 |
return [image,video]
|
134 |
|
135 |
|
136 |
+
# @app.route('/at')
|
137 |
+
# def attend():
|
138 |
+
# # Face recognition variables
|
139 |
+
# known_faces_names = ["Sarwan Sir", "Vikas","Lalit","Jasmeen","Anita Ma'am"]
|
140 |
+
# known_face_encodings = []
|
141 |
|
142 |
+
# # Load known face encodings
|
143 |
+
# sir_image = face_recognition.load_image_file("photos/sir.jpeg")
|
144 |
+
# sir_encoding = face_recognition.face_encodings(sir_image)[0]
|
145 |
|
146 |
+
# vikas_image = face_recognition.load_image_file("photos/vikas.jpg")
|
147 |
+
# vikas_encoding = face_recognition.face_encodings(vikas_image)[0]
|
148 |
|
149 |
+
# lalit_image = face_recognition.load_image_file("photos/lalit.jpg")
|
150 |
+
# lalit_encoding = face_recognition.face_encodings(lalit_image)[0]
|
151 |
|
152 |
+
# jasmine_image = face_recognition.load_image_file("photos/jasmine.jpg")
|
153 |
+
# jasmine_encoding = face_recognition.face_encodings(jasmine_image)[0]
|
154 |
|
155 |
+
# maam_image = face_recognition.load_image_file("photos/maam.png")
|
156 |
+
# maam_encoding = face_recognition.face_encodings(maam_image)[0]
|
157 |
|
158 |
+
# known_face_encodings = [sir_encoding, vikas_encoding,lalit_encoding,jasmine_encoding,maam_encoding]
|
159 |
|
160 |
+
# students = known_faces_names.copy()
|
161 |
|
162 |
+
# face_locations = []
|
163 |
+
# face_encodings = []
|
164 |
+
# face_names = []
|
165 |
|
166 |
+
# now = datetime.now()
|
167 |
+
# current_date = now.strftime("%Y-%m-%d")
|
168 |
+
# csv_file = open(f"{current_date}.csv", "a+", newline="")
|
169 |
|
170 |
+
# csv_writer = csv.writer(csv_file)
|
171 |
|
172 |
|
173 |
+
# # Function to run face recognition
|
174 |
+
# def run_face_recognition():
|
175 |
+
# video_capture = cv2.VideoCapture(0)
|
176 |
+
# s = True
|
177 |
|
178 |
+
# existing_names = set(row[0] for row in csv.reader(csv_file)) # Collect existing names from the CSV file
|
179 |
|
180 |
|
181 |
+
# while s:
|
182 |
+
# _, frame = video_capture.read()
|
183 |
+
# small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
|
184 |
+
# rgb_small_frame = small_frame[:, :, ::-1]
|
185 |
|
186 |
+
# face_locations = face_recognition.face_locations(rgb_small_frame)
|
187 |
+
# face_encodings = face_recognition.face_encodings(small_frame, face_locations)
|
188 |
+
# face_names = []
|
189 |
|
190 |
+
# for face_encoding in face_encodings:
|
191 |
+
# matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
192 |
+
# name = ""
|
193 |
+
# face_distance = face_recognition.face_distance(known_face_encodings, face_encoding)
|
194 |
+
# best_match_index = np.argmin(face_distance)
|
195 |
+
# if matches[best_match_index]:
|
196 |
+
# name = known_faces_names[best_match_index]
|
197 |
|
198 |
+
# face_names.append(name)
|
199 |
|
200 |
|
201 |
+
# for name in face_names:
|
202 |
+
# if name in known_faces_names and name in students and name not in existing_names:
|
203 |
+
# students.remove(name)
|
204 |
+
# print(students)
|
205 |
+
# print(f"Attendance recorded for {name}")
|
206 |
+
# current_time = now.strftime("%H-%M-%S")
|
207 |
+
# csv_writer.writerow([name, current_time, "Present"])
|
208 |
+
# existing_names.add(name) # Add the name to the set of existing names
|
209 |
|
210 |
+
# s = False # Set s to False to exit the loop after recording attendance
|
211 |
+
# break # Break the loop once attendance has been recorded for a name
|
212 |
|
213 |
+
# cv2.imshow("Attendance System", frame)
|
214 |
+
# if cv2.waitKey(1) & 0xFF == ord('q'):
|
215 |
+
# break
|
216 |
|
217 |
+
# video_capture.release()
|
218 |
+
# cv2.destroyAllWindows()
|
219 |
+
# csv_file.close()
|
220 |
|
221 |
+
# # Call the function to run face recognition
|
222 |
+
# run_face_recognition()
|
223 |
|
224 |
+
# return redirect(url_for('show_table'))
|
225 |
|
226 |
def gradio_interface():
|
227 |
demo = gr.Interface(
|
|
|
232 |
return demo
|
233 |
|
234 |
|
235 |
+
@app.route('/att')
|
236 |
def gradio():
|
237 |
interface = gradio_interface()
|
238 |
return interface.launch()
|