This is an extension of the unofficial implementation of Latent Distribution Adjusting for Face Anti-Spoofing using PyTorch. The code base is rewritten from PyTorch Lightning to vanilla PyTorch to ensure the better control of everything.
- Transfer from PyTorch Lightning to vanilla PyTorch
- EfficientFormerV2 support
- FastViT support
- Use config files
- Data augmentations
- TurboJPEG support for faster image decoding
- Multiple datasets training
- Compute FAS-related metrics (ACER, etc.)
- Telegram reports
- Compute metrics for each val dataset separately
- Split validation into miltiple GPUs
- Balanced sampler suitable for DDP
- Reparametrization efficiency evaluation for supported models
- Conversion to ONNX
$ python3 -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
When using EfficientFormerV2 model, put pretrained weights to weights/efficientformerv2
This repository supports sending messages after each epoch to a telegram bot.
To make it work, create .env
file with Telegram bot token and chat ids:
$ cp .env.template .env
$ nano .env
datasets
|---images
| |--img1
| |--img2
| |...
|---train.csv
|---val.csv
|---test.csv
with [*.csv] having format (label only has 2 classes: 0-Spoofing, 1-Bonafide):
image_name | label
img_name1.jpg | 0
img_name2.png | 1
...
image_name
is the relative path to the image from the locations of the *.csv file.
One can find utility to convert exisiting images dataset into format supported by current repository in utils/dataset_preparation/prepare_dataset.py
torchrun --standalone --nnodes=1 --nproc_per_node=4 train.py --config config.yaml
nproc_per_node
is the number of GPUs you want to use.