Copy of onnx-community/pyannote-segmentation-3.0 @ 733a93b647 (unchanged, mit)
Browse files- README.md +23 -0
- UPSTREAM_README.md +93 -0
- config.json +21 -0
- onnx/model_quantized.onnx +3 -0
- preprocessor_config.json +7 -0
README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model: pyannote/segmentation-3.0
|
| 4 |
+
tags:
|
| 5 |
+
- chatpanel
|
| 6 |
+
- onnx
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# pyannote-segmentation-3.0
|
| 10 |
+
|
| 11 |
+
An unchanged copy of [onnx-community/pyannote-segmentation-3.0](https://huggingface.co/onnx-community/pyannote-segmentation-3.0) at commit `733a93b6473d019a773298e08cefa686894b1854`, hosted by ChatPanel so the ChatPanel gateway downloads the models it runs from one place.
|
| 12 |
+
Nothing here was retrained, converted or edited β the files are byte-for-byte the upstream ones.
|
| 13 |
+
|
| 14 |
+
- **Licence:** `mit`, the upstream licence, unchanged.
|
| 15 |
+
- **Base model:** [pyannote/segmentation-3.0](https://huggingface.co/pyannote/segmentation-3.0) β the credit for the model belongs to its authors.
|
| 16 |
+
- **Upstream:** [onnx-community/pyannote-segmentation-3.0](https://huggingface.co/onnx-community/pyannote-segmentation-3.0) at commit `733a93b6473d019a773298e08cefa686894b1854`.
|
| 17 |
+
- **Upstream model card:** `UPSTREAM_README.md`, kept as published.
|
| 18 |
+
|
| 19 |
+
Files (SHA-256):
|
| 20 |
+
|
| 21 |
+
- `config.json` β `5a4c6bb4f49f1b47c9bd398aac78b8cd4a9f30a0ff91b5c2dc68d05e13e160cf`
|
| 22 |
+
- `onnx/model_quantized.onnx` β `93a3eb106923c9b76a7d8af07ac337dd24c2d0dcd20f1b6c55f21133e944d658`
|
| 23 |
+
- `preprocessor_config.json` β `dfc7d35a3895f8997eb94521e28b1921c03480a34fa9bcbb6bef1f1934f81480`
|
UPSTREAM_README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: pyannote/segmentation-3.0
|
| 3 |
+
library_name: transformers.js
|
| 4 |
+
license: mit
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
https://huggingface.co/pyannote/segmentation-3.0 with ONNX weights to be compatible with Transformers.js.
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
## Transformers.js (v3) usage
|
| 11 |
+
|
| 12 |
+
```js
|
| 13 |
+
import { AutoProcessor, AutoModelForAudioFrameClassification, read_audio } from '@huggingface/transformers';
|
| 14 |
+
|
| 15 |
+
// Load model and processor
|
| 16 |
+
const model_id = 'onnx-community/pyannote-segmentation-3.0';
|
| 17 |
+
const model = await AutoModelForAudioFrameClassification.from_pretrained(model_id);
|
| 18 |
+
const processor = await AutoProcessor.from_pretrained(model_id);
|
| 19 |
+
|
| 20 |
+
// Read and preprocess audio
|
| 21 |
+
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/mlk.wav';
|
| 22 |
+
const audio = await read_audio(url, processor.feature_extractor.config.sampling_rate);
|
| 23 |
+
const inputs = await processor(audio);
|
| 24 |
+
|
| 25 |
+
// Run model with inputs
|
| 26 |
+
const { logits } = await model(inputs);
|
| 27 |
+
// {
|
| 28 |
+
// logits: Tensor {
|
| 29 |
+
// dims: [ 1, 767, 7 ], // [batch_size, num_frames, num_classes]
|
| 30 |
+
// type: 'float32',
|
| 31 |
+
// data: Float32Array(5369) [ ... ],
|
| 32 |
+
// size: 5369
|
| 33 |
+
// }
|
| 34 |
+
// }
|
| 35 |
+
|
| 36 |
+
const result = processor.post_process_speaker_diarization(logits, audio.length);
|
| 37 |
+
// [
|
| 38 |
+
// [
|
| 39 |
+
// { id: 0, start: 0, end: 1.0512535626298245, confidence: 0.8220156481664611 },
|
| 40 |
+
// { id: 2, start: 1.0512535626298245, end: 2.3398869619825127, confidence: 0.9008811707860472 },
|
| 41 |
+
// ...
|
| 42 |
+
// ]
|
| 43 |
+
// ]
|
| 44 |
+
|
| 45 |
+
// Display result
|
| 46 |
+
console.table(result[0], ['start', 'end', 'id', 'confidence']);
|
| 47 |
+
// βββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββ¬βββββ¬ββββββββββββββββββββββ
|
| 48 |
+
// β (index) β start β end β id β confidence β
|
| 49 |
+
// βββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββΌβββββΌββββββββββββββββββββββ€
|
| 50 |
+
// β 0 β 0 β 1.0512535626298245 β 0 β 0.8220156481664611 β
|
| 51 |
+
// β 1 β 1.0512535626298245 β 2.3398869619825127 β 2 β 0.9008811707860472 β
|
| 52 |
+
// β 2 β 2.3398869619825127 β 3.5946089560890773 β 0 β 0.7521651315796233 β
|
| 53 |
+
// β 3 β 3.5946089560890773 β 4.578039708226655 β 2 β 0.8491978128022479 β
|
| 54 |
+
// β 4 β 4.578039708226655 β 4.594995410849717 β 0 β 0.2935352600416393 β
|
| 55 |
+
// β 5 β 4.594995410849717 β 6.121008646925269 β 3 β 0.6788051309866024 β
|
| 56 |
+
// β 6 β 6.121008646925269 β 6.256654267909762 β 0 β 0.37125512393851134 β
|
| 57 |
+
// β 7 β 6.256654267909762 β 8.630452635138397 β 2 β 0.7467035186353542 β
|
| 58 |
+
// β 8 β 8.630452635138397 β 10.088643060721703 β 0 β 0.7689364814666032 β
|
| 59 |
+
// β 9 β 10.088643060721703 β 12.58113134631177 β 2 β 0.9123324509131324 β
|
| 60 |
+
// β 10 β 12.58113134631177 β 13.005023911888312 β 0 β 0.4828358177572041 β
|
| 61 |
+
// βββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββ΄βββββ΄ββββββββββββββββββββββ
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## Torch → ONNX conversion code:
|
| 65 |
+
```py
|
| 66 |
+
# pip install torch onnx https://github.com/pyannote/pyannote-audio/archive/refs/heads/develop.zip
|
| 67 |
+
import torch
|
| 68 |
+
from pyannote.audio import Model
|
| 69 |
+
|
| 70 |
+
model = Model.from_pretrained(
|
| 71 |
+
"pyannote/segmentation-3.0",
|
| 72 |
+
use_auth_token="hf_...", # <-- Set your HF token here
|
| 73 |
+
).eval()
|
| 74 |
+
|
| 75 |
+
dummy_input = torch.zeros(2, 1, 160000)
|
| 76 |
+
torch.onnx.export(
|
| 77 |
+
model,
|
| 78 |
+
dummy_input,
|
| 79 |
+
'model.onnx',
|
| 80 |
+
do_constant_folding=True,
|
| 81 |
+
input_names=["input_values"],
|
| 82 |
+
output_names=["logits"],
|
| 83 |
+
dynamic_axes={
|
| 84 |
+
"input_values": {0: "batch_size", 1: "num_channels", 2: "num_samples"},
|
| 85 |
+
"logits": {0: "batch_size", 1: "num_frames"},
|
| 86 |
+
},
|
| 87 |
+
)
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [π€ Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
|
config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "pyannote",
|
| 3 |
+
"id2label": {
|
| 4 |
+
"0": "NO_SPEAKER",
|
| 5 |
+
"1": "SPEAKER_1",
|
| 6 |
+
"2": "SPEAKER_2",
|
| 7 |
+
"3": "SPEAKER_3",
|
| 8 |
+
"4": "SPEAKERS_1_AND_2",
|
| 9 |
+
"5": "SPEAKERS_1_AND_3",
|
| 10 |
+
"6": "SPEAKERS_2_AND_3"
|
| 11 |
+
},
|
| 12 |
+
"label2id": {
|
| 13 |
+
"NO_SPEAKER": 0,
|
| 14 |
+
"SPEAKER_1": 1,
|
| 15 |
+
"SPEAKER_2": 2,
|
| 16 |
+
"SPEAKER_3": 3,
|
| 17 |
+
"SPEAKERS_1_AND_2": 4,
|
| 18 |
+
"SPEAKERS_1_AND_3": 5,
|
| 19 |
+
"SPEAKERS_2_AND_3": 6
|
| 20 |
+
}
|
| 21 |
+
}
|
onnx/model_quantized.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93a3eb106923c9b76a7d8af07ac337dd24c2d0dcd20f1b6c55f21133e944d658
|
| 3 |
+
size 1542308
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"feature_extractor_type": "PyAnnoteFeatureExtractor",
|
| 3 |
+
"processor_class": "PyAnnoteProcessor",
|
| 4 |
+
"offset": 990,
|
| 5 |
+
"sampling_rate": 16000,
|
| 6 |
+
"step": 270
|
| 7 |
+
}
|