RajaThor commited on
Commit
a0bf13f
·
verified ·
1 Parent(s): a22697c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -266,6 +266,17 @@ def recognize_face_ui():
266
  result = recognize_face(image_path)
267
  st.write(result, unsafe_allow_html=True)
268
 
 
 
 
 
 
 
 
 
 
 
 
269
  def recognize_face_optimal_ui():
270
  st.title("🔍 Recognize Face (Optimal)")
271
  image_path = st.file_uploader("Upload Image", help="Upload an image for optimal face recognition")
@@ -332,12 +343,12 @@ def get_messages(user_email):
332
  return None
333
 
334
  # Streamlit interface for messaging
335
- def messaging_ui():
336
  st.title("💬 Messaging")
337
 
338
  if st.session_state.auth_state["signed_in"]:
339
  sender_email = st.session_state.auth_state["user"].email
340
- receiver_email = st.text_input("Receiver's Email", help="Enter the receiver's email address")
341
  message_content = st.text_area("Message Content")
342
 
343
  if st.button("Send Message"):
@@ -517,7 +528,7 @@ def display_tour_steps(steps):
517
  def main():
518
  st.sidebar.title("Options")
519
  option = st.sidebar.radio("Select Option", ["Add Person", "Recognize Face", "Delete Person", "Recognize Face (Optimal)", "Tour Guide", "Feedback", "Messaging", "History", "Delete User"])
520
-
521
  if option == "Add Person":
522
  add_person_ui()
523
  elif option == "Recognize Face":
@@ -531,11 +542,20 @@ def main():
531
  elif option == "Feedback":
532
  feedback_ui()
533
  elif option == "Messaging":
534
- messaging_ui()
 
 
 
 
535
  elif option == "History":
536
  display_history(st.session_state.auth_state["user"].email)
537
  elif option == "Delete User":
538
  delete_user_ui()
 
 
 
 
 
539
 
540
  # Run the tour guide
541
  if __name__ == "__main__":
 
266
  result = recognize_face(image_path)
267
  st.write(result, unsafe_allow_html=True)
268
 
269
+ # Extract email from the result
270
+ if "Email" in result:
271
+ email_start_index = result.find("Email: ") + len("Email: ")
272
+ email_end_index = result.find("</font>", email_start_index)
273
+ email = result[email_start_index:email_end_index]
274
+
275
+ # Add a link to the email
276
+ message_ui_url = f"http://localhost:8501/?p=Insta%27s%20EYE&p=Insta%27s%20EYE&p=Insta%27s%20EYE&em={email}"
277
+ st.markdown(f"Click [here](<{message_ui_url}>) to message {email}")
278
+
279
+ # Streamlit interface for recognizing face optimal
280
  def recognize_face_optimal_ui():
281
  st.title("🔍 Recognize Face (Optimal)")
282
  image_path = st.file_uploader("Upload Image", help="Upload an image for optimal face recognition")
 
343
  return None
344
 
345
  # Streamlit interface for messaging
346
+ def messaging_ui(recipient_email):
347
  st.title("💬 Messaging")
348
 
349
  if st.session_state.auth_state["signed_in"]:
350
  sender_email = st.session_state.auth_state["user"].email
351
+ receiver_email = st.text_input("Receiver's Email", value=recipient_email, help="Enter the receiver's email address")
352
  message_content = st.text_area("Message Content")
353
 
354
  if st.button("Send Message"):
 
528
  def main():
529
  st.sidebar.title("Options")
530
  option = st.sidebar.radio("Select Option", ["Add Person", "Recognize Face", "Delete Person", "Recognize Face (Optimal)", "Tour Guide", "Feedback", "Messaging", "History", "Delete User"])
531
+
532
  if option == "Add Person":
533
  add_person_ui()
534
  elif option == "Recognize Face":
 
542
  elif option == "Feedback":
543
  feedback_ui()
544
  elif option == "Messaging":
545
+ if "em" in st.session_state and st.session_state["em"]:
546
+ messaging_ui(st.session_state["em"])
547
+ st.session_state["em"] = None
548
+ else:
549
+ messaging_ui()
550
  elif option == "History":
551
  display_history(st.session_state.auth_state["user"].email)
552
  elif option == "Delete User":
553
  delete_user_ui()
554
+
555
+ # Handle the case when the user clicks on the email link
556
+ if "em" in st.session_state and st.session_state["em"]:
557
+ messaging_ui(st.session_state["em"])
558
+ st.session_state["em"] = None
559
 
560
  # Run the tour guide
561
  if __name__ == "__main__":