Update README.md
Browse files
README.md
CHANGED
@@ -29,7 +29,7 @@ The provided OpenVINO™ IR model is compatible with:
|
|
29 |
* OpenVINO version 2024.5.0 and higher
|
30 |
* Optimum Intel 1.21.0 and higher
|
31 |
|
32 |
-
## Running Model Inference
|
33 |
|
34 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
35 |
|
@@ -40,21 +40,63 @@ pip install optimum[openvino]
|
|
40 |
2. Run model inference:
|
41 |
|
42 |
```
|
43 |
-
from transformers import
|
44 |
-
from optimum.intel.openvino import
|
45 |
|
46 |
model_id = "OpenVINO/whisper-tiny-int4-ov"
|
47 |
-
tokenizer =
|
48 |
-
model =
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
print(text)
|
55 |
```
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
## Limitations
|
60 |
|
|
|
29 |
* OpenVINO version 2024.5.0 and higher
|
30 |
* Optimum Intel 1.21.0 and higher
|
31 |
|
32 |
+
## Running Model Inference with [Optimum Intel](https://huggingface.co/docs/optimum/intel/index)
|
33 |
|
34 |
1. Install packages required for using [Optimum Intel](https://huggingface.co/docs/optimum/intel/index) integration with the OpenVINO backend:
|
35 |
|
|
|
40 |
2. Run model inference:
|
41 |
|
42 |
```
|
43 |
+
from transformers import AutoProcessor
|
44 |
+
from optimum.intel.openvino import OVModelForSpeechSeq2Seq
|
45 |
|
46 |
model_id = "OpenVINO/whisper-tiny-int4-ov"
|
47 |
+
tokenizer = AutoProcessor.from_pretrained(model_id)
|
48 |
+
model = OVModelForSpeechSeq2Seq.from_pretrained(model_id)
|
49 |
|
50 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
51 |
+
sample = dataset[0]
|
52 |
|
53 |
+
input_features = processor(
|
54 |
+
sample["audio"]["array"],
|
55 |
+
sampling_rate=sample["audio"]["sampling_rate"],
|
56 |
+
return_tensors="pt",
|
57 |
+
).input_features
|
58 |
+
|
59 |
+
outputs = model.generate(input_features)
|
60 |
+
text = processor.batch_decode(outputs)[0]
|
61 |
print(text)
|
62 |
```
|
63 |
|
64 |
+
## Running Model Inference with [OpenVINO GenAI](https://github.com/openvinotoolkit/openvino.genai)
|
65 |
+
|
66 |
+
1. Install packages required for using OpenVINO GenAI.
|
67 |
+
```
|
68 |
+
pip install huggingface_hub
|
69 |
+
pip install -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly openvino openvino-tokenizers openvino-genai
|
70 |
+
```
|
71 |
+
|
72 |
+
2. Download model from HuggingFace Hub
|
73 |
+
|
74 |
+
```
|
75 |
+
import huggingface_hub as hf_hub
|
76 |
+
|
77 |
+
model_id = "OpenVINO/whisper-tiny-int4-ov"
|
78 |
+
model_path = "whisper-tiny-int4-ov"
|
79 |
+
|
80 |
+
hf_hub.snapshot_download(model_id, local_dir=model_path)
|
81 |
+
|
82 |
+
```
|
83 |
+
|
84 |
+
3. Run model inference:
|
85 |
+
|
86 |
+
```
|
87 |
+
import openvino_genai as ov_genai
|
88 |
+
import datasets
|
89 |
+
|
90 |
+
device = "CPU"
|
91 |
+
pipe = ov_genai.WhisperPipeline(model_path, device)
|
92 |
+
|
93 |
+
dataset = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True)
|
94 |
+
sample = dataset[0]["audio]["array"]
|
95 |
+
print(pipe.generate(sample))
|
96 |
+
```
|
97 |
+
|
98 |
+
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)
|
99 |
+
|
100 |
|
101 |
## Limitations
|
102 |
|