The CelebAMask-HQ dataset was used to train the skin segmentation model Steps to prepare the dataset:
- Download the
.zip
file from the CelebAMask-HQ repo (or use this link directly: link - Place the
CelebAMask-HQ.zip
file in the projects root directory - Run data preparation script:
python src/bin/prepare_data.py
The PSPNet model was used for skin segmentation task (trained from scratch on CeleAMask-HQ dataset).
Run the following line to train the model (assuming that dataset is already prepared)
python src/bin/celebA/train.py
To extract rPPG signal from the face:
- Segment all video frames to find the skin pixels for each frame
- Apply erosion to make the skin mask a bit smaller to prevent mask leak out of the face
- Average skin pixels for R, G and B channels
- Extract rPPG from video - after this step the R, G and B signals are present (signal length is equal to number of frames)
- Filter out pixels belonging to the skin
- Apply Plane Orthogonal to the Skin (POS) algorithm to get POS signal from the RGB signals
- Run FFT for RGB channels of rPPG signals to find the strongest frequency (which corresponds to the Heart Rate)
- Calculate the Heart Rate using the strongest frequency:
HR = strongest_freq * 60
- Raw frame
- Frame trasformed to match model input size
- Model output segmentation map (with all classes)
- Output segmentation map filtered to match
skin
andnose
labels (skin_mask
) - Raw frame with pulse extracted for each pixel and masked with
skin_mask