codevlogger2003 commited on
Commit
ff436b2
·
1 Parent(s): 73db645

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -48,9 +48,12 @@ def main(options):
48
  progress_bar.empty()
49
  gray_frame = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
50
  faces = cascade.detectMultiScale(gray_frame, 1.1, 3)
51
-
 
 
 
52
 
53
- for x,y,w,h in faces:
54
 
55
 
56
  cv2.rectangle(image, (x, y), (x+w, y+h), (4, 29, 255), 2, cv2.LINE_4)
@@ -68,7 +71,7 @@ def main(options):
68
 
69
  if 'dominant_race' in user_selected_items:
70
  emotion_label='Race: '+str(result[0]['dominant_race']).title()
71
- cv2.putText(image, emotion_label, (x, y+h+150), cv2.FONT_ITALIC,1 ,(0,0,102), 2)
72
 
73
  st.image(image, channels='BGR')
74
 
 
48
  progress_bar.empty()
49
  gray_frame = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
50
  faces = cascade.detectMultiScale(gray_frame, 1.1, 3)
51
+ faces = sorted(faces, key=lambda f: -f[2] * f[3])
52
+
53
+ if len(faces) > 0:
54
+ x,y,w,h=faces[0]
55
 
56
+
57
 
58
 
59
  cv2.rectangle(image, (x, y), (x+w, y+h), (4, 29, 255), 2, cv2.LINE_4)
 
71
 
72
  if 'dominant_race' in user_selected_items:
73
  emotion_label='Race: '+str(result[0]['dominant_race']).title()
74
+ cv2.putText(image, emotion_label, (x, y+h+150), cv2.FONT_ITALIC,1 ,(25,25,112), 2)
75
 
76
  st.image(image, channels='BGR')
77