Upload 3rd_ce_full_0304
Browse files- README.md +6 -6
- inference.py +18 -4
README.md
CHANGED
|
@@ -14,7 +14,7 @@ tags:
|
|
| 14 |
- wavlm
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# forensics_0.
|
| 18 |
|
| 19 |
**The default speech deepfake detector of the Forensics family.** WavLM-large + AASIST graph-attention, fully fine-tuned end-to-end (no frozen shortcuts) across a wide multi-source mix of TTS spoofs, voice conversion, codec artifacts, and the standard anti-spoofing benchmark suite. A combined cross-entropy + OC-Softmax + supervised-contrastive objective gives it a decision boundary that holds up well outside its own training distribution — not just on the data it saw.
|
| 20 |
|
|
@@ -27,10 +27,10 @@ Feed it 5 seconds of audio, get back a calibrated real/fake probability. Sub-1%
|
|
| 27 |
|
| 28 |
| Model | Use it for |
|
| 29 |
|---|---|
|
| 30 |
-
| **`forensics_0.
|
| 31 |
-
| [`forensics_0.
|
| 32 |
-
| [`forensics_0.
|
| 33 |
-
| [`forensics_0.
|
| 34 |
|
| 35 |
Full family: [huggingface.co/collections/eliya/forensics-speech-deepfake-detection-family](https://huggingface.co/collections/eliya/forensics-speech-deepfake-detection-family)
|
| 36 |
|
|
@@ -82,7 +82,7 @@ Consistently sub-2% EER across almost every external benchmark, with strong resu
|
|
| 82 |
## Setup
|
| 83 |
```bash
|
| 84 |
pip install -r requirements.txt # torch, torchaudio, transformers, safetensors
|
| 85 |
-
hf download eliya/forensics_0.
|
| 86 |
```
|
| 87 |
|
| 88 |
## Run
|
|
|
|
| 14 |
- wavlm
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# forensics_0.3B_base_deepfake_classifier
|
| 18 |
|
| 19 |
**The default speech deepfake detector of the Forensics family.** WavLM-large + AASIST graph-attention, fully fine-tuned end-to-end (no frozen shortcuts) across a wide multi-source mix of TTS spoofs, voice conversion, codec artifacts, and the standard anti-spoofing benchmark suite. A combined cross-entropy + OC-Softmax + supervised-contrastive objective gives it a decision boundary that holds up well outside its own training distribution — not just on the data it saw.
|
| 20 |
|
|
|
|
| 27 |
|
| 28 |
| Model | Use it for |
|
| 29 |
|---|---|
|
| 30 |
+
| **`forensics_0.3B_base_deepfake_classifier`** (this model) | general-purpose default |
|
| 31 |
+
| [`forensics_0.3B_xlsr_wild_deepfake_classifier`](https://huggingface.co/eliya/forensics_0.3B_xlsr_wild_deepfake_classifier) | uncontrolled / real-world audio |
|
| 32 |
+
| [`forensics_0.3B_v2_deepfake_age_gender_classifier`](https://huggingface.co/eliya/forensics_0.3B_v2_deepfake_age_gender_classifier) 🆕 | speaker age/gender, hardened against the newest TTS threats — our latest release |
|
| 33 |
+
| [`forensics_0.3B_wavlm_oc_softmax_deepfake_classifier`](https://huggingface.co/eliya/forensics_0.3B_wavlm_oc_softmax_deepfake_classifier) | tighter bonafide boundary, ensembling |
|
| 34 |
|
| 35 |
Full family: [huggingface.co/collections/eliya/forensics-speech-deepfake-detection-family](https://huggingface.co/collections/eliya/forensics-speech-deepfake-detection-family)
|
| 36 |
|
|
|
|
| 82 |
## Setup
|
| 83 |
```bash
|
| 84 |
pip install -r requirements.txt # torch, torchaudio, transformers, safetensors
|
| 85 |
+
hf download eliya/forensics_0.3B_base_deepfake_classifier --local-dir .
|
| 86 |
```
|
| 87 |
|
| 88 |
## Run
|
inference.py
CHANGED
|
@@ -10,6 +10,7 @@ import torchaudio
|
|
| 10 |
from model import DeepfakeDetector
|
| 11 |
|
| 12 |
CHECKPOINT = "checkpoint_epoch_5.pt"
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def load_audio(path, sr=16000, seconds=5.0):
|
|
@@ -30,12 +31,25 @@ def load_audio(path, sr=16000, seconds=5.0):
|
|
| 30 |
|
| 31 |
|
| 32 |
def load_state_dict(pt_path):
|
| 33 |
-
"""Prefers a sibling .safetensors file (no code execution risk) over the pickled .pt.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
st_path = pt_path.rsplit(".", 1)[0] + ".safetensors"
|
| 35 |
-
|
|
|
|
| 36 |
from safetensors.torch import load_file
|
| 37 |
-
return load_file(
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
return ck["model_state_dict"] if isinstance(ck, dict) and "model_state_dict" in ck else ck
|
| 40 |
|
| 41 |
|
|
|
|
| 10 |
from model import DeepfakeDetector
|
| 11 |
|
| 12 |
CHECKPOINT = "checkpoint_epoch_5.pt"
|
| 13 |
+
REPO_ID = "eliya/forensics_0.3B_base_deepfake_classifier"
|
| 14 |
|
| 15 |
|
| 16 |
def load_audio(path, sr=16000, seconds=5.0):
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
def load_state_dict(pt_path):
|
| 34 |
+
"""Prefers a sibling .safetensors file (no code execution risk) over the pickled .pt.
|
| 35 |
+
Downloads from the Hub automatically if not already present locally."""
|
| 36 |
+
from huggingface_hub import hf_hub_download
|
| 37 |
+
from huggingface_hub.errors import EntryNotFoundError
|
| 38 |
+
|
| 39 |
+
def fetch(name):
|
| 40 |
+
if os.path.exists(name):
|
| 41 |
+
return name
|
| 42 |
+
return hf_hub_download(REPO_ID, name)
|
| 43 |
+
|
| 44 |
st_path = pt_path.rsplit(".", 1)[0] + ".safetensors"
|
| 45 |
+
try:
|
| 46 |
+
local_st = fetch(st_path)
|
| 47 |
from safetensors.torch import load_file
|
| 48 |
+
return load_file(local_st)
|
| 49 |
+
except EntryNotFoundError:
|
| 50 |
+
pass
|
| 51 |
+
local_pt = fetch(pt_path)
|
| 52 |
+
ck = torch.load(local_pt, map_location="cpu", weights_only=False)
|
| 53 |
return ck["model_state_dict"] if isinstance(ck, dict) and "model_state_dict" in ck else ck
|
| 54 |
|
| 55 |
|