File size: 1,247 Bytes
6a22294 c548018 377753f c548018 377753f c548018 6a22294 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
---
license: mit
library_name: transformers.js
base_model: pyannote/segmentation-3.0
---
https://huggingface.co/pyannote/segmentation-3.0 with ONNX weights to be compatible with Transformers.js.
## Torch → ONNX conversion code:
```py
# pip install torch onnx https://github.com/pyannote/pyannote-audio/archive/refs/heads/develop.zip
import torch
from pyannote.audio import Model
model = Model.from_pretrained(
"pyannote/segmentation-3.0",
use_auth_token="hf_...", # <-- Set your HF token here
).eval()
dummy_input = torch.zeros(2, 1, 160000)
torch.onnx.export(
model,
dummy_input,
'model.onnx',
do_constant_folding=True,
input_names=["input_values"],
output_names=["logits"],
dynamic_axes={
"input_values": {0: "batch_size", 1: "num_channels", 2: "num_samples"},
"logits": {0: "batch_size", 1: "num_frames"},
},
)
```
---
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`). |