The mirror called me worried. It was right. I built a mirror that reads your face with YOLOv11 on a Raspberry Pi, works out which of 10 emotions you are showing, and answers with a roast or a compliment to match your mood.

What it does
YOLOv11-nano runs on the Pi and reads 10 emotions – happy, angry, thinking, worried, confident, and more. The mirror shows your current mood on screen, along with a roast or a compliment written for that mood. Walk up looking worried and it will tell you so, kindly or otherwise.
- Reads 10 emotions from the camera in real time
- Shows a roast or a compliment for your mood
- Smoothing and a cooldown stop the mood flickering
- Demo mode runs offline with no Pi and no camera
What it saw
In the seeded 20-frame demo, the mirror changed mood 4 times and never flickered or flipped falsely. It read thinking on frame 03 at 0.36, worried on frame 08 at 0.63, peaking at 0.69 on frame 10, happy on frame 13 at 0.68, and confident on frame 18 at 0.67 – ending on confident as its final mood.

| Frame | Mood | Confidence |
|---|---|---|
| 03 | thinking | 0.36 |
| 08 | worried | 0.63 |
| 10 | worried (peak) | 0.69 |
| 13 | happy | 0.68 |
| 18 | confident | 0.67 |
| 20 | confident (final) | – |
How it works
YOLOv11-nano finds the face, MediaPipe tracks the facial landmarks, and the mirror turns those into one of 10 emotions. Smoothing and a cooldown keep the mood steady, then the mirror picks a roast or a compliment written for that mood.

- The Pi camera captures a frame
- YOLOv11-nano finds the face
- MediaPipe landmarks feed the emotion scores
- Smoothing and a cooldown settle the mood
- The mirror shows the mood and a roast or compliment
The maths
The classifier gives every emotion a score, and the scores are normalised so they sum to 1 – each score divided by the total of all scores. The mood is the emotion with the biggest share, and that share is the confidence: worried at 0.63 means worried held 63% of the total score.
The scores are then smoothed so a single odd frame cannot flip the mood: smoothed = 0.7 * new + 0.3 * old. Each new reading moves the running score 70% of the way towards it and keeps 30% of the old value. On top of that, a mood only changes if its smoothed confidence clears a 0.35 floor, and after a change the mirror waits 5 frames – a 5-frame cooldown – before it will change mood again.
What you need
- Raspberry Pi 5
- A camera
- YOLOv11-nano
Demo mode runs offline with no Pi and no camera – it replays the seeded 20-frame demo so you can see the smoothing, cooldown and roasts work.
One thing to be plain about: Pi mode loads YOLOv11-nano and opens the camera, but the emotion classifier itself is a one-line hook – mirror.update(scores) – for your own landmark classifier. The smoothing, cooldown and roasts are finished; no specific classifier model is bundled, so you plug in the emotion model you want to use.
Build it
Install the dependencies, run the demo, then run it on the Pi.
pip install -r requirements.txtpython main.py --demopython main.pyThe code

emotion-mirror/
+-- main.py
+-- emotion_mirror/mirror.py
+-- emotion_mirror/roasts.py
+-- emotion_mirror/demo.pymirror.py holds the mood logic – normalise, smooth, and only switch mood past the floor and after the cooldown:
EMOTIONS = [
"happy", "sad", "angry", "surprised", "fearful",
"disgusted", "neutral", "thinking", "worried", "confident",
]
class EmotionMirror:
def __init__(self, floor=0.35, cooldown=5):
self.floor = floor
self.cooldown = cooldown
self.smoothed = {name: 0.0 for name in EMOTIONS}
self.mood = "neutral"
self.frames_since_change = 99
def update(self, scores):
total = sum(scores.values()) or 1.0
for name in EMOTIONS:
new = scores.get(name, 0.0) / total
self.smoothed[name] = 0.7 * new + 0.3 * self.smoothed[name]
top = max(self.smoothed, key=self.smoothed.get)
self.frames_since_change += 1
if self.smoothed[top] >= self.floor and self.frames_since_change >= self.cooldown:
if top != self.mood:
self.mood = top
self.frames_since_change = 0
return self.mood, self.smoothed[self.mood]roasts.py keeps one line per mood – a roast or a compliment for each of the 10 emotions:
ROASTS = {
"happy": "Look at you, smiling like the Wi-Fi just came back.",
"sad": "Chin up - even the Pi thinks you deserve a better day.",
"angry": "Careful, your face is doing that thing again.",
"surprised": "Yes, the mirror talks. Breathe.",
"fearful": "Relax, it is only a mirror. It cannot grade you.",
"disgusted": "That face says the code review went badly.",
"neutral": "A face of pure focus. Or pure buffering.",
"thinking": "Deep in thought, or just deciding what to eat.",
"worried": "You look worried. The deadline can wait five minutes.",
"confident": "That is the face of someone who just fixed the bug.",
}
def roast_for(mood):
return ROASTS.get(mood, ROASTS["neutral"])What broke
The mood flickered every frame – happy, worried, thinking, happy again, all in a second, because each frame’s raw scores were taken at face value. Smoothing plus the 5-frame cooldown fixed it: a mood now has to win the smoothed scores and wait out the cooldown before the mirror will switch to it.
Download the project
Unzip the project, pip install the requirements, then run main.py –demo to watch the seeded 20-frame demo change moods without flickering.
Premium Download
Get the complete project code
