jarondon82 commited on
Commit
96dcdcf
·
1 Parent(s): 176f9a1

Use detected face as reference for existing users without reference image

Browse files
Files changed (1) hide show
  1. streamlit_app.py +18 -1
streamlit_app.py CHANGED
@@ -2030,7 +2030,24 @@ def main():
2030
  width=250 # Usar ancho fijo en lugar de use_column_width
2031
  )
2032
  else:
2033
- st.info(f"The reference image for {reference_name} is not available. Please re-register this person to see their image here.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2034
 
2035
  # Limpiar el estado para la próxima ejecución
2036
  del st.session_state.matched_faces
 
2030
  width=250 # Usar ancho fijo en lugar de use_column_width
2031
  )
2032
  else:
2033
+ # Si no hay imagen de referencia, usar la imagen detectada
2034
+ st.warning(f"Using detected face as reference for {reference_name}")
2035
+
2036
+ # Guardar la imagen detectada como referencia para este usuario
2037
+ if reference_name in st.session_state.face_database:
2038
+ st.session_state.face_database[reference_name]['face_image'] = match_info["face_crop"]
2039
+
2040
+ # Guardar la base de datos actualizada
2041
+ if DATABASE_UTILS_AVAILABLE:
2042
+ save_success = save_face_database(st.session_state.face_database)
2043
+ if save_success:
2044
+ st.success("Reference image saved for future use")
2045
+
2046
+ # Mostrar la imagen detectada como referencia
2047
+ st.image(
2048
+ cv2.cvtColor(match_info["face_crop"], cv2.COLOR_BGR2RGB),
2049
+ width=250
2050
+ )
2051
 
2052
  # Limpiar el estado para la próxima ejecución
2053
  del st.session_state.matched_faces