Spaces:
Runtime error
Runtime error
Shafeek Saleem
commited on
Commit
•
775c70f
1
Parent(s):
caa436d
face recog fixed
Browse files
pages/2_Face Detection and Creating Database.py
CHANGED
@@ -56,7 +56,13 @@ def step2_page():
|
|
56 |
But remember, we should always ask for permission before taking someone's picture. We can use a smartphone or a digital camera to capture pictures, and it's important to take pictures of different people. This will help our application to have a good known-faces database!
|
57 |
"""
|
58 |
)
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
if picture:
|
61 |
image = face_recognition.load_image_file(picture)
|
62 |
st.image(image)
|
|
|
56 |
But remember, we should always ask for permission before taking someone's picture. We can use a smartphone or a digital camera to capture pictures, and it's important to take pictures of different people. This will help our application to have a good known-faces database!
|
57 |
"""
|
58 |
)
|
59 |
+
st.info("Select an image to continue!")
|
60 |
+
input_type = st.radio("Select the Input Type", ["Image", "Camera"])
|
61 |
+
|
62 |
+
if input_type == "Camera":
|
63 |
+
picture = st.camera_input("Take a picture")
|
64 |
+
else:
|
65 |
+
picture = st.file_uploader("Upload an image", type=["png", "jpg", "jpeg"])
|
66 |
if picture:
|
67 |
image = face_recognition.load_image_file(picture)
|
68 |
st.image(image)
|
pages/4_Face Recognition.py
CHANGED
@@ -54,9 +54,13 @@ def step4_page():
|
|
54 |
# Loop through each face in this image
|
55 |
cols = st.columns(len(face_encodings))
|
56 |
i = 0
|
|
|
|
|
|
|
|
|
57 |
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
|
58 |
# See if the face is a match for the known face(s)
|
59 |
-
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
|
60 |
|
61 |
name = "Unknown"
|
62 |
# If a match was found in known_face_encodings, just use the first one.
|
@@ -70,23 +74,6 @@ def step4_page():
|
|
70 |
cols[i].write("Person name: " +name)
|
71 |
i+=1
|
72 |
|
73 |
-
# # Draw a box around the face
|
74 |
-
# cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
|
75 |
-
#
|
76 |
-
# # Draw a label with a name below the face
|
77 |
-
# cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
|
78 |
-
# font = cv2.FONT_HERSHEY_DUPLEX
|
79 |
-
# cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
|
80 |
-
#
|
81 |
-
# # Display the resulting image
|
82 |
-
# cv2.imshow('Video', frame)
|
83 |
-
# # Hit 'q' on the keyboard to quit!
|
84 |
-
# if cv2.waitKey(1) & 0xFF == ord('q'):
|
85 |
-
# break
|
86 |
-
# # Release handle to the webcam
|
87 |
-
# video_capture.release()
|
88 |
-
# cv2.destroyAllWindows()
|
89 |
-
|
90 |
st.info("Click on the button below to complete this level!")
|
91 |
if st.button("Complete Level"):
|
92 |
complete_level(LEVEL)
|
|
|
54 |
# Loop through each face in this image
|
55 |
cols = st.columns(len(face_encodings))
|
56 |
i = 0
|
57 |
+
st.image(image)
|
58 |
+
st.info("Select the tolerance level you want for your model! (How much distance between faces to consider it a match. "
|
59 |
+
"Lower is more strict. 0.6 is typical best performance.)")
|
60 |
+
tolerance = st.slider('Select tolerance level', 0, 1, 0.6, 0.1)
|
61 |
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
|
62 |
# See if the face is a match for the known face(s)
|
63 |
+
matches = face_recognition.compare_faces(known_face_encodings, face_encoding, tolerance=tolerance)
|
64 |
|
65 |
name = "Unknown"
|
66 |
# If a match was found in known_face_encodings, just use the first one.
|
|
|
74 |
cols[i].write("Person name: " +name)
|
75 |
i+=1
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
st.info("Click on the button below to complete this level!")
|
78 |
if st.button("Complete Level"):
|
79 |
complete_level(LEVEL)
|