richermans commited on
Commit
52200e0
·
verified ·
1 Parent(s): 2abb379

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -0
README.md CHANGED
@@ -53,5 +53,25 @@ Notable differences from other available models include:
53
  'Finger snapping'
54
  ```
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  ## Fine-tuning
57
  [`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.
 
53
  'Finger snapping'
54
  ```
55
 
56
+ ## Inference (Onnx)
57
+ ```python
58
+ >>> from optimum.onnxruntime import ORTModelForAudioClassification
59
+
60
+ >>> model_name = "mispeech/ced-base"
61
+ >>> model = ORTModelForAudioClassification.from_pretrained(model_name, trust_remote_code=True)
62
+
63
+ >>> import torchaudio
64
+ >>> audio, sampling_rate = torchaudio.load("/path-to/JeD5V5aaaoI_931_932.wav")
65
+ >>> assert sampling_rate == 16000
66
+ >>> input_name = model.session.get_inputs()[0].name
67
+ >>> output = model(**{input_name: torch.randn(1, 16000)})
68
+ >>> logits = output.logits.squeeze()
69
+ >>> for idx in logits.argsort()[-2:][::-1]:
70
+ >>> print(f"{model.config.id2label[idx]}: {logits[idx]:.4f}")
71
+ 'Finger snapping: 0.9155'
72
+ 'Slap: 0.0567'
73
+ ```
74
+
75
+
76
  ## Fine-tuning
77
  [`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.