maxinethegreat commited on
Commit
2d9f1e0
·
1 Parent(s): 3c29a90

fix format

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -20,19 +20,19 @@ for (x, y, w, h) in faces:
20
  face = gray[y:y+h, x:x+w]
21
  face = cv2.resize(face, (48, 48), interpolation = cv2.INTER_AREA)
22
  if np.sum([face])!=0:
23
- face = face.astype('float')/255.0
24
- face = tf.keras.utils.img_to_array(face)
25
- face = np.expand_dims(face, axis=0)
26
- prediction = model.predict(face)
27
- if any(prob >.5 for prob in prediction[0]):
28
- emotion = emotions[np.argmax(prediction)]
29
- cv2.putText(frame, emotion, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (128, 128, 0), 2)
30
- cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 0), 2)
31
- else:
32
- cv2.putText(frame, low_confidence_alert, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 69, 255),
33
  2)
34
- else:
35
- cv2.putText(frame, no_face_detection_alert, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 69, 255), 2)
36
 
37
  return frame
38
 
 
20
  face = gray[y:y+h, x:x+w]
21
  face = cv2.resize(face, (48, 48), interpolation = cv2.INTER_AREA)
22
  if np.sum([face])!=0:
23
+ face = face.astype('float')/255.0
24
+ face = tf.keras.utils.img_to_array(face)
25
+ face = np.expand_dims(face, axis=0)
26
+ prediction = model.predict(face)
27
+ if any(prob >.5 for prob in prediction[0]):
28
+ emotion = emotions[np.argmax(prediction)]
29
+ cv2.putText(frame, emotion, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (128, 128, 0), 2)
30
+ cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 0), 2)
31
+ else:
32
+ cv2.putText(frame, low_confidence_alert, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 69, 255),
33
  2)
34
+ else:
35
+ cv2.putText(frame, no_face_detection_alert, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 69, 255), 2)
36
 
37
  return frame
38