At a glance
- Dates
- Context
- Technologies
- Source code
- Project repository on GitHub
Overview
Predicting where a person looks on the screen with a plain computer camera, choosing the images worth training on through active learning.
Problem
Eye-tracking devices rely on infrared cameras, which are costly and need calibrating. Can a plain camera and an AI replace them, and does active learning help when the person, the background, the light or the accessories change?
Role
Final-year course project: the dataset was recorded as a team of 3, then each student ran their own study. Mine: training protocol, selection strategies, evaluation and bias analysis.
The idea
The goal: an eye-tracking system with a plain computer camera. The face of a person following a moving point on the screen with their eyes is filmed; an AI then learns, image by image, to find where they are looking.
The usual devices, based on infrared or video cameras, are heavy and costly and need many calibrations. A standard camera would make the experiment simpler to set up, cheaper and greener.
Active learning targets, among a large number of images, those that bring the most information to the model. The study’s hypothesis: it helps predict the coordinates of the point being looked at.
Capturing the images
Each recording lasts 30 seconds. The person, sitting in front of a laptop screen, keeps still: only their gaze follows the point.
- The point bounces off the edges of the screen and changes colour, like the DVD logo; its path is drawn at random for each recording.
- The computer’s camera films the face while the coordinates of the point are recorded alongside.
- The videos are cut into images, each carrying the point’s coordinates in its name. Every image is handled on its own, not as part of a sequence.
Data and protocol
Two domains. Domain A, one person in a single setting, is the reference. Domain B brings together four people and twelve recordings: two computers, two backgrounds (classroom, white wall), accessories (cap, glasses, mask) and bright or dim light.
| Images | Domain A | Domain B |
|---|---|---|
| Training | 647 | 8,202 |
| Test | 216 | 2,051 |
Domain A: three quarters of the images for training, one quarter for the test. Domain B: 80% make up the pool the strategies draw from, 20% the test.
The model: a ResNet-18 used for regression, which predicts for each image the coordinates of the point on the screen.
- 20 epochs, batches of 10 images, a learning rate of 0.0001, the mean absolute error (MAE) as loss and the AdamW optimiser.
- Training on domain A, then 1, 2, 5, 10, 20 and 50% of domain B added incrementally: each step keeps the images of the previous ones. The loss is measured on the domain B test set.
- Three repetitions with different seeds, to compute a standard deviation and check that a result is not a lucky draw.
- Each strategy starts from scratch: starting from a model already trained by another strategy would bias the comparison.
- About 15 minutes for the first training on domain A, 1 h 40 on average for a strategy’s full session.
Two starting measures. A dummy model, which points at random on the screen without looking at the images, is 772 pixels off on average. The model trained on domain A alone makes 6.5 times more error on domain B than on A: it has learnt domain A, and domain B remains to be learnt.
The strategies compared
Each strategy picks the images of domain B to add to the training set. All of them are compared with random selection.
| Strategy (family) | How the images are chosen |
|---|---|
| Random | At random in the pool. |
| MC Dropout (50% and 25%) | Ten predictions per image, with neurons switched off at random; the images where they vary most, those the model is not sure of, are kept. |
| Data Augmentation | Ten copies of each image, brighter or darker, noisy or blurred; the images with the least stable predictions are kept. |
| Clustering (K-Means, then L2 normalisation) | The images are grouped into clusters; the sample closest to the centre of each cluster is kept. |
| Learning Loss | The model predicts the error it will make; the images with the largest expected errors are kept. |
| Mix | Data Augmentation spots the most problematic images, clustering picks the most varied among them. |
On the following charts: across, the percentage of domain B added to the training set; up, the MAE loss on the test set (lower is better). The vertical bars give the standard deviation over the three repetitions, the stars the best result obtained.
The reference: random
The simplest strategy: images taken at random from domain B. Its curve is the reference for all the others. Training: 1 h 13.
Uncertainty sampling: the model is not sure of a label
MC Dropout. Two settings: 50% then 25% of the neurons switched off, to create variation. Neither does better than random, but 25% beats 50%: switching off too many neurons biases the model, which no longer links the images together and does not learn to predict the right coordinates. Training: 1 h 18.
Data Augmentation (adversarial data). Each image is copied ten times, with a changed brightness or added blur, and the model predicts the coordinates on every copy: a way to cope with brightness and contrast issues, and to focus on the pupil rather than the pixels. Mixed results: no better loss than random. Training: 1 h 46.
Diversity sampling: the model looks for new labels
The family with the most satisfying results. Two approaches:
- K-Means, which splits the whole set of images into clusters. It links images with close features (a short distance to the centre): it diversifies little and focuses on what they have in common.
- K-Means with L2 normalisation: every image is brought to the same norm, as if on a sphere. What then counts is how its features differ, hence a true geometric diversity and better learning. There are as many clusters as images to pick.
With 50% of domain B, clustering L2 does better than random: a loss of 0.0331 against 0.0362. Training: 2 h 40.
Predict its own errors: Learning Loss
The model tries to reduce two errors at once: that of the coordinates, and that of the prediction of its own error. This second module, very noisy at first, takes over the learning: the model focuses on predicting its error and neglects the coordinates.
The method suits classification (a cat or a dog) better than an error in pixels, which is less clear-cut. Training: 1 h 50.
Mixing the best strategies
A last attempt: combining an uncertainty strategy and a diversity strategy, those that gave the best predictions. Data Augmentation spots the most problematic images, then clustering L2 picks the most varied among them. Training: 2 h 34.
Behind random up to 20% of domain B, it moves ahead at 50%.
Results
- more error on domain B for the model trained on domain A alone (MAE 0.2303 against 0.0357)
- × 6.5
- mean error of a dummy model pointing at random
- 772 px
- best loss with 50% of domain B: clustering L2 (0.0362 at random)
- 0.0331
- images in domain B, for four people and twelve settings
- 10,253
| MAE loss with 50% of domain B | Loss |
|---|---|
| Random | 0.0362 |
| Dropout 25% | 0.0427 |
| Data Augmentation | 0.0406 |
| Clustering L2 | 0.0331 |
| Learning Loss | 0.1121 |
| Mix (L2 + Data Augmentation) | 0.0341 |
To compare the predictions in pixels, each best model (the one at 50% of domain B) predicted the coordinates on every test image of domain B. Almost every strategy brings the error far below that of the starting model, but compared with random, they do not always do better. The chart at the top of the page gives the mean error in pixels of each strategy, before and after adding 50% of domain B.
Conclusion of the study. At 50% of domain B, clustering L2 and the mix do better than random, in MAE as in pixels; the uncertainty strategies and Learning Loss do worse. The gain stays small: random selection remains a hard reference to beat.