RajaThor commited on
Commit
9bce502
·
verified ·
1 Parent(s): e1ebce1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -118,18 +118,18 @@ def detect_and_align_faces(image):
118
  return aligned_faces
119
 
120
  # Add person to database
121
- def add_person(name, image_path, instagram_handle, email=None):
122
  try:
123
- encoding = load_and_encode(image_path)
124
- if not encoding:
125
- return "No face found in the provided image."
126
-
127
- # Convert NumPy arrays to lists for JSON serialization
128
- encoding = encoding[0].tolist()
129
 
130
  # Save data to Firebase Realtime Database
131
  person_data = {
132
- "encoding": encoding,
133
  "info": {
134
  "instagram_handle": instagram_handle,
135
  "instagram_link": f"https://www.instagram.com/{instagram_handle}/"
@@ -245,14 +245,14 @@ def send_feedback(feedback_data):
245
  def add_person_ui():
246
  st.title("😎 Add Person")
247
  name = st.text_input("Enter Name", help="Enter the name of the person")
248
- image_path = st.file_uploader("Upload Image", help="Upload an image containing the person's face")
249
  email = st.text_input("Enter Email (Optional)", help="Enter the person's email address (optional)")
250
  instagram_handle = st.text_input("Enter Instagram Handle", help="Enter the person's Instagram handle")
251
  if st.button("Add Person"):
252
- if not name or not image_path or not instagram_handle:
253
  st.error("Please fill all the required fields.")
254
  else:
255
- result = add_person(name, image_path, instagram_handle, email)
256
  st.success(result)
257
 
258
  # Streamlit interface for recognizing face
 
118
  return aligned_faces
119
 
120
  # Add person to database
121
+ def add_person(name, image_paths, instagram_handle, email=None):
122
  try:
123
+ encodings = []
124
+ for image_path in image_paths:
125
+ encoding = load_and_encode(image_path)
126
+ if not encoding:
127
+ return f"No face found in the image: {image_path}"
128
+ encodings.append(encoding[0].tolist())
129
 
130
  # Save data to Firebase Realtime Database
131
  person_data = {
132
+ "encodings": encodings,
133
  "info": {
134
  "instagram_handle": instagram_handle,
135
  "instagram_link": f"https://www.instagram.com/{instagram_handle}/"
 
245
  def add_person_ui():
246
  st.title("😎 Add Person")
247
  name = st.text_input("Enter Name", help="Enter the name of the person")
248
+ image_paths = st.file_uploader("Upload Image(s)", accept_multiple_files=True, help="Upload 1 to 3 images containing the person's face")
249
  email = st.text_input("Enter Email (Optional)", help="Enter the person's email address (optional)")
250
  instagram_handle = st.text_input("Enter Instagram Handle", help="Enter the person's Instagram handle")
251
  if st.button("Add Person"):
252
+ if not name or not image_paths or not instagram_handle:
253
  st.error("Please fill all the required fields.")
254
  else:
255
+ result = add_person(name, image_paths, instagram_handle, email)
256
  st.success(result)
257
 
258
  # Streamlit interface for recognizing face