Views
No views yet
hyperion/, so you do not need a separate Hyperion checkout for inference.facebook/wav2vec2-xls-r-300mmodel_ep0001.pthbonafide, spoofmodel.pth1conda create -n hyperion_grl_infer python=3.10 -y
2conda activate hyperion_grl_infer
3
4git lfs install
5git clone https://huggingface.co/RuiRuihigh/hyperion-grl-deepfake-detector
6cd hyperion-grl-deepfake-detector
7
8pip install -r requirements.txtls -lh model.pthmodel.pth is only a few KB, run:git lfs pullpython inference.py example.wav --model-dir .python inference.py a.wav b.wav c.wav --model-dir . --batch-size 8python inference.py example.wav --model-dir . --device cpupython inference.py example.wav --model-dir . --device cudaaudio: one or more input audio files to classify. Example: example.wav or a.wav b.wav c.wav.--model-dir: directory containing config.json, model.pth, and the vendored hyperion/ code. Default: ..--device: inference device. Choices: auto, cpu, cuda. Default: auto, which uses CUDA if available and otherwise uses CPU.--batch-size: number of audio files processed per batch when more than one input file is provided. Default: 8.1{
2 "label": "bonafide",
3 "score": 0.946759045124054,
4 "scores": {
5 "bonafide": 0.946759045124054,
6 "spoof": 0.053241003304719925
7 }
8}from_local_dir:1from inference import DeepfakeDetector
2
3detector = DeepfakeDetector.from_local_dir(".")
4result = detector.predict("example.wav")
5print(result)from_local_dir(".") also uses GPU automatically when CUDA is available. To force a device:1detector = DeepfakeDetector.from_local_dir(".", device="cpu")
2# or
3detector = DeepfakeDetector.from_local_dir(".", device="cuda")1from inference import DeepfakeDetector
2
3detector = DeepfakeDetector.from_local_dir(".")
4results = detector.predict_batch(["a.wav", "b.wav", "c.wav"], batch_size=8)
5
6for result in results:
7 print(result)PYTHONPATH or run the script from this directory, and pass the full model directory path:1from inference import DeepfakeDetector
2
3detector = DeepfakeDetector.from_local_dir("/path/to/hyperion-grl-deepfake-detector")
4result = detector.predict("/path/to/example.wav")
5print(result)DeepfakeDetector.from_local_dir(model_dir, device=None): loads config.json and model.pth from a local model directory. device=None means auto-select CUDA if available, otherwise CPU.DeepfakeDetector.from_pretrained(repo_id, device=None): downloads config.json and model.pth from a Hugging Face repo, then loads the model. This still requires inference.py and the vendored hyperion/ code to be importable locally.detector.predict(audio_path): runs inference for one audio file and returns a dictionary with label, score, and scores.detector.predict_batch(audio_paths, batch_size=8): runs batched inference for a list of audio files.inference.py: command line inference and Python API.config.json: model metadata and runtime settings.model.pth: checkpoint containing model_cfg and model_state_dict.hyperion/: vendored runtime modules needed to reconstruct the model.requirements.txt: Python dependencies.--model-dir . means the model files are in the current directory.wav2vec2-xls-r-300m.soundfile and resampled to 16 kHz when needed.