ONNX Model Zoo

bizenlabs/medasr-onnx

By bizenlabs · ↓ 0 · ♥ 0 · Updated 2026-02-20

What's in this repo

This page lists the files in bizenlabs/medasr-onnx, including model-fp32.onnx, model-int8.onnx.

  • 2 ONNX models (.onnx files)
  • 6 files, including 2 .md, 2 .onnx, 1 .json
  • Last updated 2026-02-20

ONNX files

File Size Download
model-fp32.onnx — Download
model-int8.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

MedASR ONNX — BizenLabs

ONNX-exported variants of google/medasr for local, offline medical speech recognition.

Published at: bizenlabs/medasr-onnx

Model Variants

Variant File Size Precision Use Case
FP32 model-fp32.onnx 405 MB Full Baseline — highest accuracy
FP16 model-fp16.onnx 204 MB Mixed Smaller footprint (auto-rejected if accuracy degrades)
INT8 model-int8.onnx 149 MB Quantized Low-resource CPU — 1.8x faster, 2.7x smaller

Quick Start

import numpy as np
import onnxruntime as ort
from transformers import AutoProcessor

processor = AutoProcessor.from_pretrained("google/medasr", trust_remote_code=True)
session = ort.InferenceSession("model-fp32.onnx", providers=["CPUExecutionProvider"])

# audio: float32 numpy array, mono, 16 kHz
encoded = processor(audio, sampling_rate=16000, return_tensors="np", padding=True)
feed = {"input_features": encoded["input_features"]}
if "attention_mask" in encoded:
    feed["attention_mask"] = encoded["attention_mask"]

logits = session.run(None, feed)[0]
token_ids = np.argmax(logits, axis=-1)
text = processor.batch_decode(token_ids)[0]

Source Model

Spec Value
Architecture Conformer-CTC (LasrForCTC)
Parameters 105M
Input 16 kHz mono audio
Vocab size 512
Training data ~5,000 hours physician dictations
WER (radiology) 4.6%
License Apache 2.0 (code) + HAI-DEF (weights)
Source google/medasr

Conversion Details

  • Exported with torch.onnx.export using legacy TorchScript path (dynamo=False)
  • ONNX opset version: 17
  • Dynamic axes: batch + sequence (supports variable-length audio)
  • FP16: mixed-precision with LayerNormalization, Softmax, ReduceMean, Attention ops kept in FP32
  • INT8: dynamic quantization on MatMul/Gemm ops
  • All variants validated against FP32 baseline (logit-level max_abs_diff + text-level WER)

See CONVERSION.md for the full process, key decisions, and reconversion checklist.

Directory Contents

File Purpose
convert_medasr.py Self-contained conversion script: export + quantize + validate + manifest
upload.py Upload artifacts to HuggingFace Hub
requirements.lock.txt Pinned Python dependencies
CONVERSION.md Detailed conversion process, key decisions, and reconversion checklist

Setup

cd tools/medasr-onnx
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.lock.txt

Login to Hugging Face (required for gated model access):

huggingface-cli login

Convert

python convert_medasr.py \
  --model-id google/medasr \
  --version 2026.02.20 \
  --output-dir ./artifacts

The script will:

  1. Export FP32 baseline and validate (structure, dynamic axes, runtime load)
  2. Build FP16 variant — auto-rejected if logit divergence or WER exceeds threshold
  3. Build INT8 variant with accuracy gate
  4. Write manifest.json with SHA256 checksums for all passing variants

To skip FP16 entirely:

python convert_medasr.py \
  --model-id google/medasr \
  --version 2026.02.20 \
  --output-dir ./artifacts \
  --skip-fp16

Upload to HuggingFace

Preview what will be uploaded:

python upload.py --version 2026.02.20 --dry-run

Upload all passing variants:

python upload.py --version 2026.02.20

Upload specific variants only:

python upload.py --version 2026.02.20 --variants fp32 int8

Reconverting (New Model Release)

When Google releases a new MedASR version:

  1. Update the transformers pin in requirements.lock.txt if the model card specifies a new commit
  2. Run conversion: python convert_medasr.py --model-id google/medasr --version YYYY.MM.DD
  3. Review the console output for any rejected variants
  4. Upload: python upload.py --version YYYY.MM.DD

See CONVERSION.md for the full reconversion checklist.

License

ONNX conversion code: Apache 2.0 Model weights: subject to google/medasr license (Apache 2.0 code + HAI-DEF weights)

Model info

onnx region:us
↓ 0 ♥ 0

Created: 2026-02-20

Updated: 2026-02-20

View on Hugging Face

Files (6)

.gitattributes
CONVERSION.md
README.md
manifest.json
model-fp32.onnx ONNX
model-int8.onnx ONNX

Related models