sehaj13 commited on
Commit
01df85b
·
verified ·
1 Parent(s): eac344b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -105,20 +105,20 @@ with app_tab:
105
  match_idx = torch.argmax(prediction)
106
  st.subheader("Face Recognition Results")
107
  # st.write("Similarity Scores:", prediction.tolist())
108
- if prediction[match_idx] >= 0.6:
109
- name = image_paths[match_idx].split('/')[-1].split('.')[0].upper()
110
 
111
  # Extract face location from InsightFace result
112
- face_info = app.get(cv2_webcam, max_num=1)[0]
113
- faceLoc = face_info.bbox.astype(int) # returns [x1, y1, x2, y2]
114
 
115
- x1, y1, x2, y2 = faceLoc
116
- cv2.rectangle(cv2_webcam, (x1, y1), (x2, y2), (0, 255, 0), 2)
117
- cv2.rectangle(cv2_webcam, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
118
- cv2.putText(cv2_webcam, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
119
 
120
  # Convert BGR to RGB before displaying in Streamlit
121
- st.image(cv2.cvtColor(cv2_webcam, cv2.COLOR_BGR2RGB), caption=f"Matched: {name}", use_column_width=True)
122
 
123
 
124
  if prediction[match_idx] >= 0.6:
 
105
  match_idx = torch.argmax(prediction)
106
  st.subheader("Face Recognition Results")
107
  # st.write("Similarity Scores:", prediction.tolist())
108
+ if prediction[match_idx] >= 0.6:
109
+ name = image_paths[match_idx].split('/')[-1].split('.')[0].upper()
110
 
111
  # Extract face location from InsightFace result
112
+ face_info = app.get(cv2_webcam, max_num=1)[0]
113
+ faceLoc = face_info.bbox.astype(int) # returns [x1, y1, x2, y2]
114
 
115
+ x1, y1, x2, y2 = faceLoc
116
+ cv2.rectangle(cv2_webcam, (x1, y1), (x2, y2), (0, 255, 0), 2)
117
+ cv2.rectangle(cv2_webcam, (x1, y2 - 35), (x2, y2), (0, 255, 0), cv2.FILLED)
118
+ cv2.putText(cv2_webcam, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
119
 
120
  # Convert BGR to RGB before displaying in Streamlit
121
+ st.image(cv2.cvtColor(cv2_webcam, cv2.COLOR_BGR2RGB), caption=f"Matched: {name}", use_column_width=True)
122
 
123
 
124
  if prediction[match_idx] >= 0.6: