Update app.py
Browse files
app.py
CHANGED
|
@@ -146,7 +146,7 @@ def add_person(name, image_path, instagram_handle, email=None):
|
|
| 146 |
except Exception as e:
|
| 147 |
return f"Failed to add person: {str(e)}"
|
| 148 |
|
| 149 |
-
# Update recognize_face function to
|
| 150 |
def recognize_face(image_path):
|
| 151 |
if not image_path:
|
| 152 |
return "Please upload an image."
|
|
@@ -176,8 +176,7 @@ def recognize_face(image_path):
|
|
| 176 |
for name, insta_handle, email in matches:
|
| 177 |
insta_link = f"https://www.instagram.com/{insta_handle}/"
|
| 178 |
insta_link_html = f'<a href="{insta_link}" target="_blank"><font color="red">{insta_handle}</font></a>'
|
| 179 |
-
|
| 180 |
-
results.append(f"- It's a picture of {name}! Insta handle: {insta_link_html}, Email: {email_link_html}")
|
| 181 |
log_action(st.session_state.auth_state["user"].email, "Recognized face")
|
| 182 |
return "\n".join(results)
|
| 183 |
else:
|
|
@@ -267,13 +266,6 @@ def recognize_face_ui():
|
|
| 267 |
result = recognize_face(image_path)
|
| 268 |
st.write(result, unsafe_allow_html=True)
|
| 269 |
|
| 270 |
-
# Add JavaScript to set the recipient's email when the email is clicked
|
| 271 |
-
st.write('<script>')
|
| 272 |
-
st.write('function set_recipient_email(email) {')
|
| 273 |
-
st.write('document.getElementById("receiver_email").value = email;')
|
| 274 |
-
st.write('}')
|
| 275 |
-
st.write('</script>')
|
| 276 |
-
|
| 277 |
def recognize_face_optimal_ui():
|
| 278 |
st.title("🔍 Recognize Face (Optimal)")
|
| 279 |
image_path = st.file_uploader("Upload Image", help="Upload an image for optimal face recognition")
|
|
@@ -345,7 +337,7 @@ def messaging_ui():
|
|
| 345 |
|
| 346 |
if st.session_state.auth_state["signed_in"]:
|
| 347 |
sender_email = st.session_state.auth_state["user"].email
|
| 348 |
-
receiver_email = st.text_input("Receiver's Email", help="Enter the receiver's email address"
|
| 349 |
message_content = st.text_area("Message Content")
|
| 350 |
|
| 351 |
if st.button("Send Message"):
|
|
|
|
| 146 |
except Exception as e:
|
| 147 |
return f"Failed to add person: {str(e)}"
|
| 148 |
|
| 149 |
+
# Update recognize_face function to handle multiple face encodings
|
| 150 |
def recognize_face(image_path):
|
| 151 |
if not image_path:
|
| 152 |
return "Please upload an image."
|
|
|
|
| 176 |
for name, insta_handle, email in matches:
|
| 177 |
insta_link = f"https://www.instagram.com/{insta_handle}/"
|
| 178 |
insta_link_html = f'<a href="{insta_link}" target="_blank"><font color="red">{insta_handle}</font></a>'
|
| 179 |
+
results.append(f"- It's a picture of {name}! Insta handle: {insta_link_html}, Email: {email}")
|
|
|
|
| 180 |
log_action(st.session_state.auth_state["user"].email, "Recognized face")
|
| 181 |
return "\n".join(results)
|
| 182 |
else:
|
|
|
|
| 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")
|
|
|
|
| 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"):
|