naymaraq commited on
Commit
df8f715
·
verified ·
1 Parent(s): 02863c9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -98,6 +98,46 @@ python <NEMO_ROOT>/examples/asr/speech_classification/frame_vad_infer.py \
98
  out_manifest_filepath=<Path of output manifest file>
99
  ```
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  ## Software Integration:
102
  **Runtime Engine(s):**
103
  * NeMo-2.0.0 <br>
 
98
  out_manifest_filepath=<Path of output manifest file>
99
  ```
100
 
101
+ ### Export a PyTorch model to ONNX
102
+
103
+ ```python
104
+ import torch, onnx
105
+ from nemo.core import typecheck
106
+ import nemo.collections.asr as nemo_asr
107
+ typecheck.set_typecheck_enabled(False)
108
+
109
+ ONNX_EXPORT_PATH = "frame_vad_multilingual_marblenet_v2.0.onnx"
110
+
111
+ # Load pretrained frame-level VAD model and move to CPU in eval mode
112
+ vad_model = nemo_asr.models.EncDecFrameClassificationModel.from_pretrained(
113
+ model_name="nvidia/frame_vad_multilingual_marblenet_v2.0"
114
+ ).eval().cpu()
115
+
116
+ # Define input example for ONNX export
117
+ B, F, T = 16, 80, 400 # batch, feature dim, sequence length
118
+ inputs = {
119
+ "processed_signal": torch.randn(B, F, T).float(),
120
+ "processed_signal_length": torch.full((B,), T, dtype=torch.long)
121
+ }
122
+
123
+ # Export model to ONNX
124
+ torch.onnx.export(
125
+ model=vad_model,
126
+ args=inputs,
127
+ f="frame_vad_multilingual_marblenet_v2.0.onnx",
128
+ input_names=["processed_signal", "processed_signal_length"],
129
+ output_names=["output"],
130
+ dynamic_axes={
131
+ "processed_signal": {0: "batch_size", 2: "sequence_length"},
132
+ "processed_signal_length": {0: "batch_size"},
133
+ "output": {0: "batch_size", 1: "sequence_length"}
134
+ }
135
+ )
136
+
137
+ # Validate exported ONNX model
138
+ onnx.checker.check_model(onnx.load(ONNX_EXPORT_PATH))
139
+ ```
140
+
141
  ## Software Integration:
142
  **Runtime Engine(s):**
143
  * NeMo-2.0.0 <br>