Views
No views yet
nvidia/diar_streaming_sortformer_4spk-v2
into the 🤗 Transformers format. The weights are bit-identical to the original NeMo checkpoint — only the
serialization (.nemo → config.json + safetensors) and the surrounding inference code differ. No retraining,
fine-tuning, quantization, or merging was performed.1import torch
2from transformers import AutoFeatureExtractor, AutoModelForAudioFrameClassification
3
4model_id = "<this-repo>"
5feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
6model = AutoModelForAudioFrameClassification.from_pretrained(model_id).eval()
7
8# `audio` is a 16 kHz mono waveform. The offline path peak-normalizes the waveform first:
9import numpy as np
10audio = audio / (np.abs(audio).max() + 1e-3)
11inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
12with torch.no_grad():
13 probs = model(**inputs).logits.sigmoid() # (batch, num_frames, num_speakers)1# NOTE: the streaming path expects features extracted WITHOUT peak-normalization.
2inputs = feature_extractor(audio, sampling_rate=16000, return_tensors="pt")
3with torch.no_grad():
4 probs = model.diarize_streaming(inputs.input_features, attention_mask=inputs.attention_mask)examples/pytorch/speaker-diarization/.transformers/src/transformers/models/sortformer/convert_sortformer_nemo_to_hf.py. The HF
implementation was validated to reproduce the original NeMo model to float precision:| Path | max|Δ| vs NeMo |
|---|---|
| Offline network (identical features) | ~4e-8 |
| Offline full pipeline (real audio) | ~5e-7 |
Streaming (forward_streaming, AOSC) | ~6e-7 |