Vansh Chugh commited on
Commit
c0306c8
·
1 Parent(s): e04f90f

fix: drop z-score norm, ckpt never applied it

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -24,7 +24,7 @@ import torch
24
  from pyharp import ModelCard, build_endpoint, load_audio
25
 
26
  from models.moe_research.w2v2_moe_fz24_aasist import Model
27
- from utils.tools.tools import pad, norm
28
 
29
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
30
  CKPT_PATH = os.path.join(os.path.dirname(__file__), "checkpoints", "fz24_moe_aasist.ckpt")
@@ -85,15 +85,14 @@ model_card = ModelCard(
85
 
86
 
87
  def preprocess(sig):
88
- """Mirrors the original repo's eval-time pipeline: pad or crop to ~4s, then
89
- per-utterance z-score normalize (the model expects a raw normalized
90
- waveform, not wav2vec2's own feature-extractor normalization). The
91
- original assumed pre-formatted 16kHz mono ASVspoof audio and skipped this
92
- step; HARP users upload arbitrary files, so mono/resample is added here."""
93
  sig = sig.to_mono().resample(16000)
94
  wav = sig.audio_data[0, 0].cpu().numpy()
95
  wav = pad(wav, TRUNCATE)
96
- wav = norm(wav)
97
  return torch.tensor(wav, dtype=torch.float32)
98
 
99
 
 
24
  from pyharp import ModelCard, build_endpoint, load_audio
25
 
26
  from models.moe_research.w2v2_moe_fz24_aasist import Model
27
+ from utils.tools.tools import pad
28
 
29
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
30
  CKPT_PATH = os.path.join(os.path.dirname(__file__), "checkpoints", "fz24_moe_aasist.ckpt")
 
85
 
86
 
87
  def preprocess(sig):
88
+ """Pad/crop to ~4s, raw waveform, no z-score norm -- matches
89
+ asvspoof_data_DA.py, the data module this checkpoint's hparams.yaml
90
+ actually names. Mono/16kHz resample added since HARP users upload
91
+ arbitrary files, unlike the original's pre-formatted 16kHz mono
92
+ ASVspoof set."""
93
  sig = sig.to_mono().resample(16000)
94
  wav = sig.audio_data[0, 0].cpu().numpy()
95
  wav = pad(wav, TRUNCATE)
 
96
  return torch.tensor(wav, dtype=torch.float32)
97
 
98