RajaThor commited on
Commit
81a2368
·
verified ·
1 Parent(s): 2ad3981

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -172,8 +172,8 @@ def recognize_face_optimal(image_path):
172
  for name, data in ref.get().items():
173
  known_encoding = np.array(data["encoding"])
174
  similarity_score = face_recognition.face_distance([known_encoding], unknown_encoding[0])[0]
175
- if similarity_score < 0.50: # Adjust the threshold as needed
176
- continue # Skip this match if similarity score is below 50.00%
177
  matches.append((name, similarity_score))
178
 
179
  if matches:
@@ -231,7 +231,10 @@ def recognize_face_optimal_ui():
231
  image_path = st.file_uploader("Upload Image", help="Upload an image for optimal face recognition")
232
  if st.button("Recognize Face (Optimal)"):
233
  result = recognize_face_optimal(image_path)
234
- st.write(result, unsafe_allow_html=True)
 
 
 
235
 
236
  # Streamlit interface for deleting a person
237
  def delete_person_ui():
 
172
  for name, data in ref.get().items():
173
  known_encoding = np.array(data["encoding"])
174
  similarity_score = face_recognition.face_distance([known_encoding], unknown_encoding[0])[0]
175
+ if similarity_score < 0.50: # Only consider matches above 50.00% similarity
176
+ continue
177
  matches.append((name, similarity_score))
178
 
179
  if matches:
 
231
  image_path = st.file_uploader("Upload Image", help="Upload an image for optimal face recognition")
232
  if st.button("Recognize Face (Optimal)"):
233
  result = recognize_face_optimal(image_path)
234
+ if "not found" in result.lower(): # Check if "not found" is in the result message
235
+ st.error(result)
236
+ else:
237
+ st.write(result, unsafe_allow_html=True)
238
 
239
  # Streamlit interface for deleting a person
240
  def delete_person_ui():