Spaces:
Runtime error
Runtime error
maxinethegreat
commited on
Commit
·
3c29a90
1
Parent(s):
bdfc502
fix format
Browse files
app.py
CHANGED
@@ -19,12 +19,11 @@ low_confidence_alert = "Cannot Detect Emotion"
|
|
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 |
-
|
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 |
-
|
28 |
if any(prob >.5 for prob in prediction[0]):
|
29 |
emotion = emotions[np.argmax(prediction)]
|
30 |
cv2.putText(frame, emotion, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (128, 128, 0), 2)
|
|
|
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)
|