Skip to content

Commit 6be9078

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 6995a91 commit 6be9078

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

computer_vision/emotion_detection/emotion.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"sad": "sad_emoji.webp",
2121
"angry": "angry_emoji.jpg",
2222
"surprise": "surprise_emoji.png",
23-
"neutral": "neutral_emoji.webp"
23+
"neutral": "neutral_emoji.webp",
2424
}
2525

2626
while True:
@@ -38,11 +38,11 @@
3838
# Use DeepFace to analyze the face in the frame
3939
try:
4040
analysis = DeepFace.analyze(
41-
frame,
42-
actions=['emotion'],
43-
enforce_detection=False # ✅ FIXED: Removed 'model_name'
41+
frame,
42+
actions=["emotion"],
43+
enforce_detection=False, # ✅ FIXED: Removed 'model_name'
4444
)
45-
detected_emotion = analysis[0]['dominant_emotion']
45+
detected_emotion = analysis[0]["dominant_emotion"]
4646

4747
# Add the latest emotion to the queue
4848
emotion_queue.append(detected_emotion)
@@ -63,8 +63,15 @@
6363
frame = cv2.cvtColor(np.array(frame_pil), cv2.COLOR_RGB2BGR)
6464

6565
# Display detected emotion text
66-
cv2.putText(frame, detected_emotion.capitalize(), (50, 180),
67-
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
66+
cv2.putText(
67+
frame,
68+
detected_emotion.capitalize(),
69+
(50, 180),
70+
cv2.FONT_HERSHEY_SIMPLEX,
71+
1,
72+
(0, 255, 0),
73+
2,
74+
)
6875

6976
except Exception as e:
7077
print("Error:", e)
@@ -73,8 +80,8 @@
7380
cv2.imshow("Live Emoji Detection", frame)
7481

7582
# Press 'q' to exit
76-
if cv2.waitKey(1) & 0xFF == ord('q'):
83+
if cv2.waitKey(1) & 0xFF == ord("q"):
7784
break
7885

7986
cap.release()
80-
cv2.destroyAllWindows()
87+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)