Spaces:
Runtime error
Runtime error
Commit ·
3ac844f
1
Parent(s): 9eafb00
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,27 +53,37 @@ def detect_and_match_face(frame, known_faces, known_names):
|
|
| 53 |
def main():
|
| 54 |
st.title("Face Recognition App")
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
# Read each frame from the webcam
|
| 63 |
-
ret, frame = video_capture.read()
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
break
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
if __name__ == "__main__":
|
| 79 |
main()
|
|
|
|
| 53 |
def main():
|
| 54 |
st.title("Face Recognition App")
|
| 55 |
|
| 56 |
+
# Login system
|
| 57 |
+
username = st.sidebar.text_input("Username")
|
| 58 |
+
password = st.sidebar.text_input("Password", type="password")
|
| 59 |
|
| 60 |
+
if username == "your_username" and password == "your_password":
|
| 61 |
+
st.sidebar.success("Logged In")
|
| 62 |
+
st.write("Welcome, {}".format(username))
|
| 63 |
|
| 64 |
+
known_faces, known_names = load_known_faces()
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
# OpenCV webcam setup
|
| 67 |
+
video_capture = cv2.VideoCapture(0)
|
| 68 |
|
| 69 |
+
while True:
|
| 70 |
+
# Read each frame from the webcam
|
| 71 |
+
ret, frame = video_capture.read()
|
| 72 |
|
| 73 |
+
# Detect and match faces in the frame
|
| 74 |
+
frame_with_faces = detect_and_match_face(frame, known_faces, known_names)
|
|
|
|
| 75 |
|
| 76 |
+
# Display the frame with faces
|
| 77 |
+
st.image(frame_with_faces, channels="BGR", use_column_width=True)
|
| 78 |
+
|
| 79 |
+
# Break the loop if the user clicks the 'Stop' button
|
| 80 |
+
if st.button("Stop"):
|
| 81 |
+
break
|
| 82 |
+
|
| 83 |
+
# Release the webcam
|
| 84 |
+
video_capture.release()
|
| 85 |
+
else:
|
| 86 |
+
st.sidebar.warning("Incorrect username or password")
|
| 87 |
|
| 88 |
if __name__ == "__main__":
|
| 89 |
main()
|