commit files to HF hub
Browse files- README.md +25 -0
- config.json +98 -0
- inference.py +10 -0
- openvino_model.bin +3 -0
- openvino_model.xml +0 -0
- preprocessor_config.json +13 -0
README.md
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- openvino
|
6 |
+
---
|
7 |
+
|
8 |
+
# MIT/ast-finetuned-speech-commands-v2
|
9 |
+
|
10 |
+
This is the [MIT/ast-finetuned-speech-commands-v2](https://huggingface.co/MIT/ast-finetuned-speech-commands-v2) model converted to [OpenVINO](https://openvino.ai), for accellerated inference.
|
11 |
+
|
12 |
+
An example of how to do inference on this model:
|
13 |
+
```python
|
14 |
+
from optimum.intel.openvino import OVModelForAudioClassification
|
15 |
+
from transformers import AutoTokenizer, pipeline
|
16 |
+
|
17 |
+
# model_id should be set to either a local directory or a model available on the HuggingFace hub.
|
18 |
+
model_id = "helenai/MIT-ast-finetuned-speech-commands-v2-ov"
|
19 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
20 |
+
model = OVModelForAudioClassification.from_pretrained(model_id)
|
21 |
+
pipe = pipeline("audio-classification", model=model, feature_extractor=feature_extractor)
|
22 |
+
result = pipe("https://datasets-server.huggingface.co/assets/speech_commands/--/v0.01/test/38/audio/audio.mp3")
|
23 |
+
print(result)
|
24 |
+
```
|
25 |
+
|
config.json
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "MIT/ast-finetuned-speech-commands-v2",
|
3 |
+
"architectures": [
|
4 |
+
"ASTForAudioClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.0,
|
7 |
+
"frequency_stride": 10,
|
8 |
+
"hidden_act": "gelu",
|
9 |
+
"hidden_dropout_prob": 0.0,
|
10 |
+
"hidden_size": 768,
|
11 |
+
"id2label": {
|
12 |
+
"0": "backward",
|
13 |
+
"1": "follow",
|
14 |
+
"2": "five",
|
15 |
+
"3": "bed",
|
16 |
+
"4": "zero",
|
17 |
+
"5": "on",
|
18 |
+
"6": "learn",
|
19 |
+
"7": "two",
|
20 |
+
"8": "house",
|
21 |
+
"9": "tree",
|
22 |
+
"10": "dog",
|
23 |
+
"11": "stop",
|
24 |
+
"12": "seven",
|
25 |
+
"13": "eight",
|
26 |
+
"14": "down",
|
27 |
+
"15": "six",
|
28 |
+
"16": "forward",
|
29 |
+
"17": "cat",
|
30 |
+
"18": "right",
|
31 |
+
"19": "visual",
|
32 |
+
"20": "four",
|
33 |
+
"21": "wow",
|
34 |
+
"22": "no",
|
35 |
+
"23": "nine",
|
36 |
+
"24": "off",
|
37 |
+
"25": "three",
|
38 |
+
"26": "left",
|
39 |
+
"27": "marvin",
|
40 |
+
"28": "yes",
|
41 |
+
"29": "up",
|
42 |
+
"30": "sheila",
|
43 |
+
"31": "happy",
|
44 |
+
"32": "bird",
|
45 |
+
"33": "go",
|
46 |
+
"34": "one"
|
47 |
+
},
|
48 |
+
"initializer_range": 0.02,
|
49 |
+
"intermediate_size": 3072,
|
50 |
+
"label2id": {
|
51 |
+
"backward": 0,
|
52 |
+
"bed": 3,
|
53 |
+
"bird": 32,
|
54 |
+
"cat": 17,
|
55 |
+
"dog": 10,
|
56 |
+
"down": 14,
|
57 |
+
"eight": 13,
|
58 |
+
"five": 2,
|
59 |
+
"follow": 1,
|
60 |
+
"forward": 16,
|
61 |
+
"four": 20,
|
62 |
+
"go": 33,
|
63 |
+
"happy": 31,
|
64 |
+
"house": 8,
|
65 |
+
"learn": 6,
|
66 |
+
"left": 26,
|
67 |
+
"marvin": 27,
|
68 |
+
"nine": 23,
|
69 |
+
"no": 22,
|
70 |
+
"off": 24,
|
71 |
+
"on": 5,
|
72 |
+
"one": 34,
|
73 |
+
"right": 18,
|
74 |
+
"seven": 12,
|
75 |
+
"sheila": 30,
|
76 |
+
"six": 15,
|
77 |
+
"stop": 11,
|
78 |
+
"three": 25,
|
79 |
+
"tree": 9,
|
80 |
+
"two": 7,
|
81 |
+
"up": 29,
|
82 |
+
"visual": 19,
|
83 |
+
"wow": 21,
|
84 |
+
"yes": 28,
|
85 |
+
"zero": 4
|
86 |
+
},
|
87 |
+
"layer_norm_eps": 1e-12,
|
88 |
+
"max_length": 128,
|
89 |
+
"model_type": "audio-spectrogram-transformer",
|
90 |
+
"num_attention_heads": 12,
|
91 |
+
"num_hidden_layers": 12,
|
92 |
+
"num_mel_bins": 128,
|
93 |
+
"patch_size": 16,
|
94 |
+
"qkv_bias": true,
|
95 |
+
"time_stride": 10,
|
96 |
+
"torch_dtype": "float32",
|
97 |
+
"transformers_version": "4.26.1"
|
98 |
+
}
|
inference.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from optimum.intel.openvino import OVModelForAudioClassification
|
2 |
+
from transformers import AutoTokenizer, pipeline
|
3 |
+
|
4 |
+
# model_id should be set to either a local directory or a model available on the HuggingFace hub.
|
5 |
+
model_id = "helenai/MIT-ast-finetuned-speech-commands-v2-ov"
|
6 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
7 |
+
model = OVModelForAudioClassification.from_pretrained(model_id)
|
8 |
+
pipe = pipeline("audio-classification", model=model, feature_extractor=feature_extractor)
|
9 |
+
result = pipe("https://datasets-server.huggingface.co/assets/speech_commands/--/v0.01/test/38/audio/audio.mp3")
|
10 |
+
print(result)
|
openvino_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:89a88fc7b9be32a3c8e60ad6738d24f33ee1dbc4e611a3d1b8bee5a4ef7d4095
|
3 |
+
size 170794314
|
openvino_model.xml
ADDED
The diff for this file is too large to render.
See raw diff
|
|
preprocessor_config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": true,
|
3 |
+
"feature_extractor_type": "ASTFeatureExtractor",
|
4 |
+
"feature_size": 1,
|
5 |
+
"max_length": 128,
|
6 |
+
"mean": -6.845978,
|
7 |
+
"num_mel_bins": 128,
|
8 |
+
"padding_side": "right",
|
9 |
+
"padding_value": 0.0,
|
10 |
+
"return_attention_mask": false,
|
11 |
+
"sampling_rate": 16000,
|
12 |
+
"std": 5.5654526
|
13 |
+
}
|