GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jelendu/face-emotion-detection-alzheimers: Explore the intersection of technology and healthcare with our ‘Face Emotion Detection for Alzheimer’s Care’ project. This repository is dedicated to developing AI-driven solutions to understand and respond to the emotional states of Alzheimer’s patients, aiming to improve their quality of life.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
docs
docs
 
 
.gitignore
.gitignore
 
 
Face_emotion_Detection_FER.ipynb
Face_emotion_Detection_FER.ipynb
 
 
README.md
README.md
 
 
app.py
app.py
 
 
config.py
config.py
 
 
emotion_detector.py
emotion_detector.py
 
 
mood_mapper.py
mood_mapper.py
 
 
music_player.py
music_player.py
 
 
requirements.txt
requirements.txt
 
 
setup_assets.py
setup_assets.py
 
 

Repository files navigation

Facial Emotion Detection in Alzheimer's Patients

Overview

This project applies machine learning to detect facial emotions in Alzheimer's patients, with the goal of aiding in their care and understanding their emotional states.

It now includes a zero-interaction desktop application: a webcam continuously watches the patient's face, detects their emotional state in real time, and automatically plays mood-appropriate music. The patient never needs to press a button or operate any interface — a caregiver starts the app once and it runs in the background.

🌐 Try it in your browser (no install)

A live demo runs entirely in the browser — face detection, emotion recognition, mood smoothing, and generative music, all client-side. No video ever leaves your device.

Test it locally right now:

python -m http.server 8765 --directory docs

then open http://localhost:8765/demo.html, click ▶ Start, and allow camera access. Smile, frown, or look surprised and watch the mood (and music) follow. "Demo mode" is on by default so mood changes happen within seconds; unchecking it uses the slower, care-setting timings.

This project is Case 001 on the Evidence Board portfolio, which lives in its own repository (jelendu.github.io).

Live demo (no install): https://jelendu.github.io/face-emotion-detection-alzheimers/demo.html — served by this repo's GitHub Pages (Settings → Pages → branch main, folder /docs).

How it works

webcam ──> face detection ──> emotion classification ──> mood smoothing ──> music playback
           (YuNet, OpenCV)     (FER+ ONNX model)          (majority vote     (pygame,
                                                           + hold time)       crossfade)
  1. Face detection — each analyzed frame goes through YuNet, a lightweight modern face detector. The largest face (the patient, closest to camera) is used.
  2. Emotion classification — the face crop is classified by FER+, an ONNX model trained on the FER-2013 dataset family (the same emotion vocabulary used by the fer library in the original research notebook). It outputs 8 emotions: neutral, happiness, surprise, sadness, anger, disgust, fear, contempt.
  3. Mood smoothing — raw per-frame predictions flicker, so the mood is decided by a majority vote over a 20-second sliding window, and once the music changes it is held for at least 45 seconds. Music transitions use a 4-second crossfade so they are never jarring.
  4. Music playback — the detected mood selects a folder of music, and tracks from that folder play continuously in shuffled order.

Emotion → music mapping

The music mirrors the detected emotion:

Detected emotion Music category Style
happiness, surprise happy upbeat, bouncy
neutral, contempt calm gentle ambient background
sadness sad slow, melancholy piano
anger, disgust rock driving rock, distorted guitar + drums
fear horror eerie drones and unsettling tones

The mapping, timings, and volume are all adjustable in config.py (desktop) and at the top of docs/demo.html (web demo) — e.g. if you prefer calming music for an agitated patient rather than rock, it's a two-line change.

Installation

Requires Python 3.10+ and a webcam.

pip install -r requirements.txt
python setup_assets.py     # downloads the two ONNX models (~35 MB) and
                           # generates built-in ambient music for every mood

Running

python app.py              # headless — recommended for care settings
python app.py --preview    # shows a camera window with the detected emotion (for testing)

Stop with Ctrl+C (or q in the preview window).

Adding the patient's own music (recommended)

Familiar, personally meaningful music is especially effective for people with Alzheimer's. Drop MP3/OGG/WAV files into the mood folders:

music/
  happy/    ← upbeat favourites
  calm/     ← easy background listening
  sad/      ← slow, wistful songs
  rock/     ← energetic rock tracks
  horror/   ← eerie, suspenseful pieces

The synthesized ambient tracks created by setup_assets.py make the app fully functional out of the box, but the patient's own favourites from their youth will always work better.

Repository contents

File Purpose
docs/demo.html Browser demo — face-api.js + Web Audio, fully client-side
docs/index.html Redirect to the Evidence Board portfolio (moved to its own repo)
app.py Main application — capture loop, zero-interaction operation
emotion_detector.py YuNet face detection + FER+ emotion inference
mood_mapper.py Sliding-window mood smoothing and hold logic
music_player.py Crossfading, category-based music playback
config.py All tunable settings (mapping, timings, volume)
setup_assets.py One-time setup: model download + built-in music generation
Face_emotion_Detection_FER.ipynb Original research notebook from the Samsung fellowship (FER library experiments and EfficientNet data-augmentation work)

Notes on the original notebook

The Jupyter notebook contains the original exploration: data-augmentation transforms for an EfficientNet pipeline (excluding ColorJitter to avoid lighting bias) and emotion detection experiments with the fer library on static images. The desktop app uses the FER+ ONNX model instead of the fer pip package because it covers the same emotion set while avoiding the heavy TensorFlow dependency, making it fast and reliable on ordinary CPUs.

Contribute

This project welcomes feedback, corrections, and collaborations to improve and expand its impact.

About

Explore the intersection of technology and healthcare with our ‘Face Emotion Detection for Alzheimer’s Care’ project. This repository is dedicated to developing AI-driven solutions to understand and respond to the emotional states of Alzheimer’s patients, aiming to improve their quality of life.

colab.research.google.com/github/jelendu/Python-Learning-Projects/blob/main/Face_emotion_Detection_FER.ipynb

Topics

alzheimers-diseasecomputer-visionconvolutional-neural-networksemotion-recognitionfacial-expression-analysisfacial-expression-recognitionfacial-recognitionhealthcarepatient-carepython

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.