← Projects

CogniShift

Year
2025
Tags
#typescript#python#react.js#flask#pytorch

A learning environment that adapts to how the student is feeling. It reads engagement, boredom, confusion and frustration from the webcam and adjusts the lesson to match. This was my final-year project for a BEng (Hons) in Software Engineering at Informatics Institute of Technology, in collaboration with the University of Westminster.

CogniShift architecture: webcam frames go to a local CNN that predicts four affective states, an RL agent picks an adaptation, and the learning platform applies it

The problem

How a student feels has a big effect on how well they learn, but most e-learning platforms show everyone the same content in the same way. Research systems that do respond to emotion usually need powerful hardware, and many send webcam video to a server, which raises real privacy concerns.

CogniShift aims to do this on ordinary laptops, without the video ever leaving the student’s device.

How it works

Reading the student’s state. A lightweight CNN looks at webcam frames and predicts four states at once: engagement, boredom, confusion and frustration. Its predictions are averaged over a short window, so a single odd frame doesn’t trigger a reaction. The model is exported to ONNX so it can run in the browser, and frames are processed locally rather than uploaded.

Deciding what to do. A reinforcement learning agent (a DQN) gets the detected state, along with how well the student is answering, time on task, hint usage and how long they’ve been in their current state. It picks one of six actions:

  • Increase difficulty
  • Add scaffolding (hints, smaller steps)
  • Gamify the task
  • Calm the interface (less clutter, slower pace)
  • Offer encouragement
  • Do nothing

The reward function reflects how a good tutor behaves. It rewards engagement and improving answers. Frustration or boredom that keeps going is penalised more the longer it lasts. Brief confusion is treated as productive struggle. Interrupting a student who is already engaged, or changing things too often, is penalised.

Keeping the student in control. By default, each suggestion appears as a card that the student can accept or dismiss. An auto-apply mode makes changes straight away.

Timeline of the four affective states over a session

An analytics view shows how each state changed over the session.

Results

I trained and compared six lightweight CNN backbones on the DAiSEE dataset. Because the dataset is heavily imbalanced, every model scored 81–87% accuracy whether or not it could spot the rarer states, so I compared them on macro-F1 and AUC-ROC instead, which weight every state equally.

MobileNetV2 matched the ResNet-18 baseline’s macro-F1 (0.57) with about 80% fewer parameters and 5× fewer FLOPs. It runs in about 40 ms per frame on a CPU in the browser, which is fast enough for real time. ShuffleNetV2 is faster still (about 17 ms) and a good alternative for low-end machines, at a small cost in accuracy.

In simulated sessions, the agent learned a cautious policy. It pushed answer correctness close to 100% and kept engagement steady, stepping in only when a negative state persisted.

What I learned

  • Be suspicious of good numbers. My first experiments on a smaller dataset gave very high accuracy. It turned out the model had overfitted and wouldn’t generalise, so I went back to the harder DAiSEE dataset.
  • Simplify the labels. DAiSEE rates each state on a four-point scale. Collapsing it to low/high, and switching to a multi-task model with focal loss, is what finally gave usable results. It also gave the agent clearer signals to act on.

Built with React and TypeScript on the front end and a Flask API for the agent, with PyTorch models trained on Kaggle GPUs.