Downloads · 30 days
5
7% of all-time downloads
huzaifanasirrr/ai-music-deepfake-detector
ai-music-deepfake-detector is a audio classification model from huzaifanasirrr. Use it for the audio classification task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
[](https://www.python.org/downloads/) [](https://pytorch.org/) [](https://opensource.org/licenses/MIT) [](https://github.com/Huzaifanasir95/AI-Music-DeepFake-Detector)
Downloads · 30 days
5
7% of all-time downloads
All-time downloads
74
Public
Repo size
264 MB
Likes
1
Public
Click a slice to open those files.
.pth263 MB · 100%
From the Hugging Face model README
A hybrid deep learning system that combines an autoencoder with a transformer architecture to detect AI-generated music with 95% accuracy. The model achieves 100% recall on authentic music (zero false negatives) while maintaining 90% recall on AI-generated tracks.
Key Features:
Audio → Mel-Spectrogram → Autoencoder (Encoder + Decoder)
↓
Latent Features → Transformer (6 layers)
↓
Fusion Layer → Classifier → [Real/AI]
Components:
| Metric | Real Music | AI Music |
|---|---|---|
| Precision | 90.91% | 100.00% |
| Recall | 100.00% | 90.00% |
| F1-Score | 95.24% | 94.74% |
| Overall Accuracy | 95.00% |
Confusion Matrix:
import torch
import torchaudio
import torchaudio.transforms as T
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(repo_id="huzaifanasirrr/ai-music-deepfake-detector",
filename="best_model.pth")
# Load model (you'll need the model architecture from the repo)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
checkpoint = torch.load(model_path, map_location=device)
# Load and preprocess audio
audio, sr = torchaudio.load("audio_file.wav")
if sr != 22050:
resampler = T.Resample(sr, 22050)
audio = resampler(audio)
# Extract mel-spectrogram
mel_transform = T.MelSpectrogram(
sample_rate=22050,
n_fft=2048,
hop_length=512,
n_mels=128
)
mel_spec = mel_transform(audio)
# Normalize
mel_spec = (mel_spec - mel_spec.mean()) / (mel_spec.std() + 1e-8)
# Inference
model.eval()
with torch.no_grad():
output = model(mel_spec.unsqueeze(0).to(device))
prediction = torch.argmax(output, dim=1).item()
print("Real Music" if prediction == 0 else "AI Generated")
Training Data:
Splits:
best_model.pth - PyTorch checkpoint (80.41 MB)model_architecture.json - Complete model specificationstraining_summary.json - Training history (42 epochs)training_curves.png - Loss and accuracy visualizationconfusion_matrix.png - Test set resultsconfig.yaml - Full configurationrequirements.txt - DependenciesIf you use this model in your research, please cite:
@software{nasir2025aimusic,
author = {Nasir, Huzaifa},
title = {AI Music DeepFake Detector: A Hybrid Autoencoder-Transformer Approach},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/huzaifanasirrr/ai-music-deepfake-detector},
note = {GitHub: https://github.com/Huzaifanasir95/AI-Music-DeepFake-Detector}
}
Huzaifa Nasir
National University of Computer and Emerging Sciences (FAST-NUCES), Islamabad, Pakistan
📧 [email protected]
🔗 GitHub Repository
MIT License - See LICENSE file for details.
Research conducted at FAST-NUCES Islamabad. Inspired by recent advances in audio deepfake detection and transformer-based architectures for audio processing.