richermans commited on
Commit
9eef8c0
·
verified ·
1 Parent(s): 41da630

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +19 -0
README.md CHANGED
@@ -52,5 +52,24 @@ Notable differences from other available models include:
52
  'Finger snapping'
53
  ```
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  ## Fine-tuning
56
  [`example_finetune_esc50.ipynb`](https://github.com/jimbozhang/hf_transformers_custom_model_ced/blob/main/example_finetune_esc50.ipynb) demonstrates how to train a linear head on the ESC-50 dataset with the CED encoder frozen.
 
52
  'Finger snapping'
53
  ```
54
 
55
+ ## Inference (Onnx)
56
+ ```python
57
+ >>> from optimum.onnxruntime import ORTModelForAudioClassification
58
+
59
+ >>> model_name = "mispeech/ced-mini"
60
+ >>> model = ORTModelForAudioClassification.from_pretrained(model_name, trust_remote_code=True)
61
+
62
+ >>> import torchaudio
63
+ >>> audio, sampling_rate = torchaudio.load("/path-to/JeD5V5aaaoI_931_932.wav")
64
+ >>> assert sampling_rate == 16000
65
+ >>> input_name = model.session.get_inputs()[0].name
66
+ >>> output = model(**{input_name: torch.randn(1, 16000)})
67
+ >>> logits = output.logits.squeeze()
68
+ >>> for idx in logits.argsort()[-2:][::-1]:
69
+ >>> print(f"{model.config.id2label[idx]}: {logits[idx]:.4f}")
70
+ 'Finger snapping: 0.9155'
71
+ 'Slap: 0.0567'
72
+ ```
73
+
74
  ## Fine-tuning
75
  [`example_finetune_esc50.ipynb`](https://github.com/jimbozhang/hf_transformers_custom_model_ced/blob/main/example_finetune_esc50.ipynb) demonstrates how to train a linear head on the ESC-50 dataset with the CED encoder frozen.