/asp

Automatic anti-spoofing pipeline

Primary LanguagePython

Anti-Spoofing Project

Report

The pipeline details, experiments, ablations, and results are presented in the wandb report.

Installation guide

To get started install the requirements

pip install -r ./requirements.txt

Then download train data (ASVSpoof2019 dataset)

sudo apt install axel
bash loader.sh

Model training

This project implements RawNet2 model for anti-spoofing.

To train model from scratch run

python3 train.py -c asp/configs/train.json

For fine-tuning pretrained model from checkpoint, --resume parameter is applied. For example, continuing training model with train.json config organized as follows

python3 train.py -c nv/configs/train.json -r saved/models/final/<run_id>/<any_checkpoint>.pth

Inference stage

Checkpoint should be located in default_test_model directory. Pretrained model can be downloaded by running python code

import gdown
gdown.download("https://drive.google.com/uc?id=1HBDp__V5AGJacbhnaoQiC4g0wxizEFWa", "default_test_model/checkpoint.pth")

Model evaluation is executed by command

python3 test.py \
   -i default_test_model/test \
   -r default_test_model/checkpoint.pth \
   -o output.csv \
   -l False
  • -i (--input-dir) provide the path to directory with input audio files. The model classify them to bonafide/spoof.
  • -r (--resume) provide the path to model checkpoint. Note that config file is expected to be in the same dir with name config.json.
  • -o (--output) specify output .csv file path. The dataframe with results will be saved there. Each row contains
    1. Filename of audio.
    2. Logits predicted by model (the first one corresponds to the spoof target).
    3. Probs calculated by softmax of logits.
    4. Prediction specifying the forecasted type (spoof for fake, bonafide for real).
  • -l (--log-wandb) determine log results to wandb project or not. If True, authorization in command line is needed. Name of project can be changed in the config file.

Running with default parameters

python3 test.py

Credits

The code of model is based on an asr-template project and notebook with SincNet implementation.