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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
- model_hub_mixin
|
| 4 |
- pytorch_model_hub_mixin
|
| 5 |
+
license: cc-by-nc-4.0
|
| 6 |
+
datasets:
|
| 7 |
+
- mueller91/MLAAD
|
| 8 |
+
- jungjee/asvspoof5
|
| 9 |
+
- Bisher/ASVspoof_2019_LA
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
pipeline_tag: audio-classification
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# AASIST3: KAN-Enhanced AASIST Speech Deepfake Detection
|
| 16 |
+
|
| 17 |
+
[](https://huggingface.co/MTUCI/AASIST3)
|
| 18 |
+
[](https://creativecommons.org/licenses/by-nc-nd/4.0/)
|
| 19 |
+
|
| 20 |
+
This repository contains the original implementation of **AASIST3: KAN-Enhanced AASIST Speech Deepfake Detection using SSL Features and Additional Regularization for the ASVspoof 2024 Challenge**.
|
| 21 |
+
|
| 22 |
+
## Paper
|
| 23 |
+
|
| 24 |
+
**AASIST3: KAN-Enhanced AASIST Speech Deepfake Detection using SSL Features and Additional Regularization for the ASVspoof 2024 Challenge**
|
| 25 |
+
|
| 26 |
+
*This is the original implementation of the paper. The model weights provided here are NOT the same weights used in the paper results.*
|
| 27 |
+
|
| 28 |
+
## Overview
|
| 29 |
+
|
| 30 |
+
AASIST3 is an enhanced version of the AASIST (Anti-spoofing with Adaptive Softmax and Instance-wise Temperature) architecture that incorporates **Kolmogorov-Arnold Networks (KAN)** for improved speech deepfake detection. The model leverages:
|
| 31 |
+
|
| 32 |
+
- **Self-Supervised Learning (SSL) Features**: Uses Wav2Vec2 encoder for robust audio representation
|
| 33 |
+
- **KAN Linear Layers**: Kolmogorov-Arnold Networks for enhanced feature transformation
|
| 34 |
+
- **Graph Attention Networks (GAT)**: For spatial and temporal feature modeling
|
| 35 |
+
- **Multi-branch Inference**: Multiple inference branches for robust decision making
|
| 36 |
+
|
| 37 |
+
## Architecture
|
| 38 |
+
|
| 39 |
+
The AASIST3 model consists of several key components:
|
| 40 |
+
|
| 41 |
+
1. **Wav2Vec2 Encoder**: Extracts SSL features from raw audio
|
| 42 |
+
2. **KAN Bridge**: Transforms SSL features using Kolmogorov-Arnold Networks
|
| 43 |
+
3. **Residual Encoder**: Processes features through multiple residual blocks
|
| 44 |
+
4. **Graph Attention Networks**:
|
| 45 |
+
- GAT-S: Spatial attention mechanism
|
| 46 |
+
- GAT-T: Temporal attention mechanism
|
| 47 |
+
5. **Multi-branch Inference**: Four parallel inference branches with master tokens
|
| 48 |
+
6. **KAN Output Layer**: Final classification using KAN linear layers
|
| 49 |
+
|
| 50 |
+
### Key Innovations
|
| 51 |
+
|
| 52 |
+
- **KAN Integration**: Replaces traditional linear layers with KAN linear layers for better feature approximation
|
| 53 |
+
- **Enhanced Regularization**: Additional dropout and regularization techniques
|
| 54 |
+
- **Multi-dataset Training**: Trained on multiple ASVspoof datasets for robustness
|
| 55 |
+
|
| 56 |
+
## 🚀 Quick Start
|
| 57 |
+
|
| 58 |
+
### Installation
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
git clone https://github.com/your-username/AASIST3.git
|
| 62 |
+
cd AASIST3
|
| 63 |
+
pip install -r requirements.txt
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### Loading the Model
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
from model import aasist3
|
| 70 |
+
|
| 71 |
+
# Load the model from Hugging Face Hub
|
| 72 |
+
model = aasist3.from_pretrained("MTUCI/AASIST3")
|
| 73 |
+
model.eval()
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### Basic Usage
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
import torch
|
| 80 |
+
import torchaudio
|
| 81 |
+
|
| 82 |
+
# Load and preprocess audio
|
| 83 |
+
audio, sr = torchaudio.load("audio_file.wav")
|
| 84 |
+
# Ensure audio is 16kHz and mono
|
| 85 |
+
if sr != 16000:
|
| 86 |
+
audio = torchaudio.transforms.Resample(sr, 16000)(audio)
|
| 87 |
+
if audio.shape[0] > 1:
|
| 88 |
+
audio = torch.mean(audio, dim=0, keepdim=True)
|
| 89 |
+
|
| 90 |
+
# Prepare input (model expects ~4 seconds of audio at 16kHz)
|
| 91 |
+
# Pad or truncate to 64600 samples
|
| 92 |
+
if audio.shape[1] < 64600:
|
| 93 |
+
audio = torch.nn.functional.pad(audio, (0, 64600 - audio.shape[1]))
|
| 94 |
+
else:
|
| 95 |
+
audio = audio[:, :64600]
|
| 96 |
+
|
| 97 |
+
# Run inference
|
| 98 |
+
with torch.no_grad():
|
| 99 |
+
output = model(audio)
|
| 100 |
+
probabilities = torch.softmax(output, dim=1)
|
| 101 |
+
prediction = torch.argmax(probabilities, dim=1)
|
| 102 |
+
|
| 103 |
+
# prediction: 0 = bonafide, 1 = spoof
|
| 104 |
+
print(f"Prediction: {'Bonafide' if prediction.item() == 0 else 'Spoof'}")
|
| 105 |
+
print(f"Confidence: {probabilities.max().item():.3f}")
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## Training Details
|
| 109 |
+
|
| 110 |
+
### Datasets Used
|
| 111 |
+
|
| 112 |
+
The model was trained on a combination of multiple datasets:
|
| 113 |
+
|
| 114 |
+
- **ASVspoof 2019 LA** (Logical Access)
|
| 115 |
+
- **ASVspoof 2024 (ASVspoof5)**
|
| 116 |
+
- **MLAAD** (Multi-Language Audio Anti-Spoofing Dataset)
|
| 117 |
+
- **M-AILABS** (Multi-Language Audio Dataset)
|
| 118 |
+
|
| 119 |
+
### Training Configuration
|
| 120 |
+
|
| 121 |
+
- **Epochs**: 20
|
| 122 |
+
- **Batch Size**: 12 (training), 24 (validation)
|
| 123 |
+
- **Learning Rate**: 1e-4
|
| 124 |
+
- **Optimizer**: AdamW
|
| 125 |
+
- **Loss Function**: CrossEntropyLoss
|
| 126 |
+
- **Gradient Accumulation Steps**: 2
|
| 127 |
+
|
| 128 |
+
### Hardware
|
| 129 |
+
|
| 130 |
+
- **GPUs**: 2xA100 40GB
|
| 131 |
+
- **Framework**: PyTorch with Accelerate for distributed training
|
| 132 |
+
|
| 133 |
+
## Advanced Usage
|
| 134 |
+
|
| 135 |
+
### Custom Training
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
# Train the model
|
| 139 |
+
bash train.sh
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
### Validation
|
| 143 |
+
|
| 144 |
+
```bash
|
| 145 |
+
# Run validation on test sets
|
| 146 |
+
bash validate.sh
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
### Model Configuration
|
| 150 |
+
|
| 151 |
+
The model can be configured through the `configs/train.yaml` file:
|
| 152 |
+
|
| 153 |
+
```yaml
|
| 154 |
+
# Key parameters
|
| 155 |
+
num_epochs: 20
|
| 156 |
+
train_batch_size: 12
|
| 157 |
+
val_batch_size: 24
|
| 158 |
+
learning_rate: 1e-4
|
| 159 |
+
gradient_accumulation_steps: 2
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
## 🤝 Citation
|
| 164 |
+
|
| 165 |
+
If you use this implementation in your research, please cite the original paper:
|
| 166 |
+
|
| 167 |
+
```bibtex
|
| 168 |
+
@inproceedings{borodin24_asvspoof,
|
| 169 |
+
title = {AASIST3: KAN-enhanced AASIST speech deepfake detection using SSL features and additional regularization for the ASVspoof 2024 Challenge},
|
| 170 |
+
author = {Kirill Borodin and Vasiliy Kudryavtsev and Dmitrii Korzh and Alexey Efimenko and Grach Mkrtchian and Mikhail Gorodnichev and Oleg Y. Rogov},
|
| 171 |
+
year = {2024},
|
| 172 |
+
booktitle = {The Automatic Speaker Verification Spoofing Countermeasures Workshop (ASVspoof 2024)},
|
| 173 |
+
pages = {48--55},
|
| 174 |
+
doi = {10.21437/ASVspoof.2024-8},
|
| 175 |
+
}
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
## License
|
| 179 |
+
|
| 180 |
+
This project is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0) - see the [LICENSE](LICENSE) file for details.
|
| 181 |
+
|
| 182 |
+
This license allows you to:
|
| 183 |
+
- **Share**: Copy and redistribute the material in any medium or format
|
| 184 |
+
- **Attribution**: You must give appropriate credit, provide a link to the license, and indicate if changes were made
|
| 185 |
+
|
| 186 |
+
But does NOT allow:
|
| 187 |
+
- **Commercial use**: You may not use the material for commercial purposes
|
| 188 |
+
- **Derivatives**: You may not distribute modified versions of the material
|
| 189 |
+
|
| 190 |
+
For more information, visit: https://creativecommons.org/licenses/by-nc-nd/4.0/
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
**Disclaimer**: This is a research implementation. The model weights provided are for demonstration purposes and may not match the exact performance reported in the paper.
|