-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_all.py
More file actions
55 lines (42 loc) · 1.47 KB
/
Copy pathrun_all.py
File metadata and controls
55 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
run_all.py — exhaustive sweep across every model, dataset, and visualisation.
Useful as a smoke test to confirm every combination works end-to-end.
Expect this to take several minutes as each model is downloaded on first run
and cached by HuggingFace Hub locally (~/.cache/huggingface).
Run:
uv run python examples/run_all.py
uv run python examples/run_all.py res/spoof/spoof.flac # custom file
"""
import sys
from pathlib import Path
from Jabberjay import Dataset, Jabberjay, Model, Visualisation
AUDIO = Path(sys.argv[1]) if len(sys.argv) > 1 else Path("res/bonafide/bonafide.flac")
jj = Jabberjay()
audio = jj.load(AUDIO)
print(f"Audio: {AUDIO}\n")
print(f"{'Model':<30} {'Label':<10} {'Confidence':>10}")
print("-" * 56)
def row(tag: str, result) -> None:
print(f"{tag:<30} {result.label:<10} {result.confidence:>10.1%}")
# Self-contained models
for model in (
Model.Classical,
Model.RawNet2,
Model.Spectra0,
Model.SpectraAASIST,
Model.SpectraAASIST3,
Model.Wav2Vec2,
Model.HuBERT,
Model.WavLM,
):
row(model.value, jj.detect(audio, model=model))
# AST — one model per dataset
for ds in Dataset:
row(f"AST/{ds.value}", jj.detect(audio, model=Model.AST, dataset=ds))
# VIT — one model per (dataset x visualisation) combination
for vis in Visualisation:
for ds in Dataset:
row(
f"VIT/{ds.value}/{vis.value}",
jj.detect(audio, model=Model.VIT, dataset=ds, visualisation=vis),
)