Skip to content

Commit 2bdec25

Browse files
Fix Whisper Intel® OpenVINO imports with fallback (microsoft#308)
Co-authored-by: xieofxie <xieofxie@126.com>
1 parent 11d132b commit 2bdec25

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

openai-whisper-large-v3-turbo/OpenVINO/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ This example demonstrates how to export and optimize OpenAI's Whisper Large V3 T
1414
Install the required packages:
1515

1616
```bash
17+
# For recent pip versions (supports direct URL syntax)
18+
python -m pip install "olive-ai[openvino] @ git+https://github.com/microsoft/olive.git@main"
19+
20+
# For older pip versions (fallback format)
1721
python -m pip install "git+https://github.com/microsoft/olive.git@main#egg=olive-ai[openvino]"
1822
```
1923

openai-whisper-large-v3-turbo/OpenVINO/convert_whisper_to_ovir.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,19 @@ def reshape_and_save_to_tmp(input_ov_path: str, reshape_dict: dict, tmp_ov_path:
125125
@param reshape_dict: Dictionary of input names to new shapes.
126126
@param tmp_ov_path: Path to save the reshaped OpenVINO model.
127127
"""
128-
from openvino.runtime import Core, serialize
129-
core = Core()
130-
ov_model = core.read_model(input_ov_path)
131-
ov_model.reshape(reshape_dict)
132-
serialize(ov_model, tmp_ov_path)
128+
try:
129+
from openvino.runtime import Core, serialize
130+
core = Core()
131+
ov_model = core.read_model(input_ov_path)
132+
ov_model.reshape(reshape_dict)
133+
serialize(ov_model, tmp_ov_path)
134+
except (ImportError, AttributeError):
135+
# fallback to the newer 2025+ version of openvino that doesn't have openvino.runtime
136+
import openvino as ov
137+
core = ov.Core()
138+
ov_model = core.read_model(input_ov_path)
139+
ov_model.reshape(reshape_dict)
140+
ov.serialize(ov_model, tmp_ov_path)
133141

134142

135143
def update_genai_overrides(encapsulate_json, w_config: WhisperConfig, enable_npu_ws: bool, reshape: bool, output_directory: str):

0 commit comments

Comments
 (0)