video_helper.faces.asd module
video_helper.faces.asd
Active-Speaker Detection (ASD): given the on-screen faces during a window and the concurrent audio, score which face is producing the speech.
Two interchangeable engines behind one interface:
LipMotionASD— a zero-weight proxy. Scores the temporal variance of mouth openness per track, gated by audio activity in the window. Always available, fully offline, no download. The graceful-degradation default.LightASD— the accurate audio-visual cross-attention model (Light-ASD) run through ONNX Runtime. Downloaded on first use from the user’s mirror; if the weights are not hosted yet,available()is False and the caller falls back to the proxy.
The engine is called per clip window (not per whole video): the smart-sampling
harness (video_helper.faces.sampling) picks a small set of windows so this
heavy step runs on a fraction of the footage.
- class video_helper.faces.asd.ASDEngine[source]
Bases:
objectInterface: score each track’s speaking likelihood within one clip window.
- name = 'base'
- class video_helper.faces.asd.LightASD[source]
Bases:
ASDEngineLight-ASD (Junhua-Liao et al., CVPR 2023) via PyTorch — accurate engine.
Loads the pretrained weights (
light_asd.pth, research license) into the vendored_lightasdmodel and scores each face track with the model’s own audio-visual head. No ONNX: a faithful ONNX export of the MFCC front-end is fragile, so we run the real network. Degrades to unavailable (the harness swaps in the lip-motion proxy) if torch or the weights are missing.Preprocessing matches the original exactly: audio → 13-cepstrum MFCC with fps-adjusted windows; visual → 112x112 grayscale mouth crops fed RAW (the model normalises
(x/255 - 0.4161)/0.1688internally — feeding an already /255 array would double-divide). Audio runs at ~4x the visual frame rate, so we align to4 * T_visualMFCC frames; the two front-ends reduce to a common length, and we min-clip to be safe.- name = 'light-asd'
- class video_helper.faces.asd.LipMotionASD[source]
Bases:
ASDEngineWeights-free proxy: lip-motion variance × audio activity.
- name = 'lip-motion'