LovnishVerma commited on
Commit
9e9e8ca
·
verified ·
1 Parent(s): 7dc8b9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -42,7 +42,6 @@ emotion_labels = ['angry', 'fear', 'happy', 'neutral', 'sad', 'surprise']
42
  # Initialize MTCNN for face detection
43
  mtcnn = MTCNN()
44
 
45
- # Load known faces and names
46
  # Load known faces and names
47
  known_faces = []
48
  known_names = []
@@ -122,6 +121,9 @@ def process_frame(frame):
122
  cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
123
  cv2.putText(frame, result_text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
124
 
 
 
 
125
  return frame, result_text
126
 
127
 
@@ -177,16 +179,14 @@ st.markdown("### MongoDB Records")
177
  records = collection.find().sort("timestamp", -1) # Sort records by timestamp in descending order
178
 
179
  for record in records:
180
- col1, col2, col3 = st.columns([3, 3, 1])
181
  with col1:
182
  st.write(f"**Name**: {record['name']}")
183
  with col2:
184
  st.write(f"**Emotion**: {record['emotion']}")
185
- with col3:
186
- st.write(f"**Timestamp**: {record['timestamp']}")
187
 
188
- # Delete record button
189
- delete_button = st.button(f"Delete {record['_id']}", key=record['_id'])
190
  if delete_button:
191
  collection.delete_one({"_id": record["_id"]})
192
- st.success(f"Record with ID {record['_id']} has been deleted.")
 
42
  # Initialize MTCNN for face detection
43
  mtcnn = MTCNN()
44
 
 
45
  # Load known faces and names
46
  known_faces = []
47
  known_names = []
 
121
  cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
122
  cv2.putText(frame, result_text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
123
 
124
+ else:
125
+ result_text = "No face detected!"
126
+
127
  return frame, result_text
128
 
129
 
 
179
  records = collection.find().sort("timestamp", -1) # Sort records by timestamp in descending order
180
 
181
  for record in records:
182
+ col1, col2 = st.columns([3, 3])
183
  with col1:
184
  st.write(f"**Name**: {record['name']}")
185
  with col2:
186
  st.write(f"**Emotion**: {record['emotion']}")
 
 
187
 
188
+ # Delete record button without showing ID
189
+ delete_button = st.button(f"Delete Record", key=record['_id'])
190
  if delete_button:
191
  collection.delete_one({"_id": record["_id"]})
192
+ st.success(f"Record with ID {record['_id']} has been deleted.")