Update README.md
Browse files
README.md
CHANGED
@@ -15,7 +15,8 @@ The provided OpenVINO™ IR model is compatible with:
|
|
15 |
* OpenVINO version 2024.5.0 and higher
|
16 |
* Optimum Intel 1.21.0 and higher
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
21 |
|
@@ -26,21 +27,62 @@ pip install optimum[openvino]
|
|
26 |
2. Run model inference:
|
27 |
|
28 |
```
|
29 |
-
from transformers import
|
30 |
-
from optimum.intel.openvino import
|
31 |
|
32 |
model_id = "OpenVINO/whisper-tiny-fp16-ov"
|
33 |
-
tokenizer =
|
34 |
-
model =
|
|
|
|
|
|
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
outputs = model.generate(
|
39 |
-
text =
|
40 |
print(text)
|
41 |
```
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
## Limitations
|
46 |
|
|
|
15 |
* OpenVINO version 2024.5.0 and higher
|
16 |
* Optimum Intel 1.21.0 and higher
|
17 |
|
18 |
+
|
19 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
20 |
|
21 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
22 |
|
|
|
27 |
2. Run model inference:
|
28 |
|
29 |
```
|
30 |
+
from transformers import AutoProcessor
|
31 |
+
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
32 |
|
33 |
model_id = "OpenVINO/whisper-tiny-fp16-ov"
|
34 |
+
tokenizer = AutoProcessor.from_pretrained(model_id)
|
35 |
+
model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
|
36 |
+
|
37 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
38 |
+
sample = dataset[0]
|
39 |
|
40 |
+
input_features = processor(
|
41 |
+
sample["audio"]["array"],
|
42 |
+
sampling_rate=sample["audio"]["sampling_rate"],
|
43 |
+
return_tensors="pt",
|
44 |
+
).input_features
|
45 |
|
46 |
+
outputs = model.generate(input_features)
|
47 |
+
text = processor.batch_decode(outputs)[0]
|
48 |
print(text)
|
49 |
```
|
50 |
|
51 |
+
## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
|
52 |
+
|
53 |
+
1. Install packages required for using OpenVINO GenAI.
|
54 |
+
```
|
55 |
+
pip install huggingface_hub
|
56 |
+
pip install -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly openvino openvino-tokenizers openvino-genai
|
57 |
+
```
|
58 |
+
|
59 |
+
2. Download model from HuggingFace Hub
|
60 |
+
|
61 |
+
```
|
62 |
+
import huggingface_hub as hf_hub
|
63 |
+
|
64 |
+
model_id = "OpenVINO/whisper-tiny-fp16-ov"
|
65 |
+
model_path = "whisper-tiny-fp16-ov"
|
66 |
+
|
67 |
+
hf_hub.snapshot_download(model_id, local_dir=model_path)
|
68 |
+
|
69 |
+
```
|
70 |
+
|
71 |
+
3. Run model inference:
|
72 |
+
|
73 |
+
```
|
74 |
+
import openvino_genai as ov_genai
|
75 |
+
import datasets
|
76 |
+
|
77 |
+
device = "CPU"
|
78 |
+
pipe = ov_genai.WhisperPipeline(model_path, device)
|
79 |
+
|
80 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
81 |
+
sample = dataset[0]["audio]["array"]
|
82 |
+
print(pipe.generate(sample))
|
83 |
+
```
|
84 |
+
|
85 |
+
More GenAI usage examples can be found in OpenVINO GenAI library [docs](https://github.com/openvinotoolkit/openvino.genai/blob/master/src/README.md) and [samples](https://github.com/openvinotoolkit/openvino.genai?tab=readme-ov-file#openvino-genai-samples)
|
86 |
|
87 |
## Limitations
|
88 |
|