Spaces:
Sleeping
Sleeping
Commit
·
133c7e7
1
Parent(s):
24a86cb
Update app.py
Browse files
app.py
CHANGED
@@ -72,24 +72,27 @@ if img_file_buffer is not None:
|
|
72 |
faces = face_cascade.detectMultiScale(
|
73 |
image=img_gray, scaleFactor=1.3, minNeighbors=5)
|
74 |
st.write("gray")
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
93 |
|
94 |
#########################
|
95 |
imgS = cv2.resize(image,(0,0),None,0.25,0.25)
|
|
|
72 |
faces = face_cascade.detectMultiScale(
|
73 |
image=img_gray, scaleFactor=1.3, minNeighbors=5)
|
74 |
st.write("gray")
|
75 |
+
try:
|
76 |
+
for (x, y, w, h) in faces:
|
77 |
+
cv2.rectangle(img=img, pt1=(x, y), pt2=(
|
78 |
+
x + w, y + h), color=(255, 0, 0), thickness=2)
|
79 |
+
roi_gray = img_gray[y:y + h, x:x + w]
|
80 |
+
roi_gray = cv2.resize(roi_gray, (48, 48), interpolation=cv2.INTER_AREA)
|
81 |
+
if np.sum([roi_gray]) != 0:
|
82 |
+
roi = roi_gray.astype('float') / 255.0
|
83 |
+
roi = img_to_array(roi)
|
84 |
+
roi = np.expand_dims(roi, axis=0)
|
85 |
+
prediction = classifier.predict(roi)[0]
|
86 |
+
maxindex = int(np.argmax(prediction))
|
87 |
+
finalout = emotion_dict[maxindex]
|
88 |
+
output = str(finalout)
|
89 |
+
st.write(output)
|
90 |
+
label_position = (x, y)
|
91 |
+
img = cv2.putText(img, output, label_position, cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
|
92 |
+
st.image(img, use_column_width=True)
|
93 |
+
st.write("emotion done")
|
94 |
+
except:
|
95 |
+
st.write("face is not clear")
|
96 |
|
97 |
#########################
|
98 |
imgS = cv2.resize(image,(0,0),None,0.25,0.25)
|