From b3388df649aab3186bf0a88cd0c58592cacc9013 Mon Sep 17 00:00:00 2001 From: rasapala Date: Thu, 7 May 2026 09:39:46 +0200 Subject: [PATCH 1/5] Quick fix --- .gitignore | 1 + .../download_model.py | 45 +++++++------------ .../download_model_requirements.txt | 7 ++- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index cd26093dfa..c404eb8cb8 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ tmp/ *.tar.gz models genhtml +.github/skills/ diff --git a/demos/python_demos/clip_image_classification/download_model.py b/demos/python_demos/clip_image_classification/download_model.py index aa2a3bd852..e3bd257896 100644 --- a/demos/python_demos/clip_image_classification/download_model.py +++ b/demos/python_demos/clip_image_classification/download_model.py @@ -14,39 +14,26 @@ # limitations under the License. #***************************************************************************** -from transformers import CLIPProcessor, CLIPModel -from PIL import Image -import openvino as ov +from optimum.intel import OVModelForZeroShotImageClassification import os model_id = "openai/clip-vit-base-patch16" -print(f'Downloading pretrained model {model_id} ...') - -model = CLIPModel.from_pretrained(model_id) -processor = CLIPProcessor.from_pretrained(model_id) - -# create OpenVINO core object instance -core = ov.Core() -model.config.torchscript = True -input_labels = ['cat', 'dog', 'wolf', 'tiger', 'man', 'horse', 'frog', 'tree', 'house', 'computer'] -text_descriptions = [f"This is a photo of a {label}" for label in input_labels] -image = Image.new('RGB', (800, 600)) -model_inputs = processor(text=text_descriptions, images=[image], return_tensors="pt", padding=True) +model_path = "model/1" -print(f'Converting pretrained model {model_id} ...') -ov_model = ov.convert_model(model, example_input=dict(model_inputs)) -for idx, out in enumerate(ov_model.outputs): - out.get_tensor().set_names({f"out_{idx}"}) -print(f'Saving converted model {model_id} ...') -ov.save_model(ov_model, 'clip-vit-base-patch16.xml') +print(f"Exporting {model_id} to OpenVINO IR via optimum-intel ...") +ov_model = OVModelForZeroShotImageClassification.from_pretrained(model_id, export=True) -print(f'Creating OpenVINO Model Server model directories ...') -model_path = "model/1" -if not os.path.exists(model_path): - os.mkdir("model") - os.mkdir(model_path) +os.makedirs(model_path, exist_ok=True) +ov_model.save_pretrained(model_path) -os.replace("clip-vit-base-patch16.bin", os.path.join(model_path,"clip-vit-base-patch16.bin")) -os.replace("clip-vit-base-patch16.xml", os.path.join(model_path,"clip-vit-base-patch16.xml")) +# OVMS expects flat .xml/.bin in the version directory. +# optimum-intel saves them as openvino_model.xml/.bin; rename to keep the existing graph.pbtxt working. +for src, dst in ( + ("openvino_model.xml", "clip-vit-base-patch16.xml"), + ("openvino_model.bin", "clip-vit-base-patch16.bin"), +): + src_path = os.path.join(model_path, src) + if os.path.exists(src_path): + os.replace(src_path, os.path.join(model_path, dst)) -print(f'Model ready') +print("Model ready") diff --git a/demos/python_demos/clip_image_classification/download_model_requirements.txt b/demos/python_demos/clip_image_classification/download_model_requirements.txt index 61f27f8a64..997a89baa9 100644 --- a/demos/python_demos/clip_image_classification/download_model_requirements.txt +++ b/demos/python_demos/clip_image_classification/download_model_requirements.txt @@ -1,8 +1,7 @@ --extra-index-url "https://download.pytorch.org/whl/cpu" ---extra-index-url "https://storage.openvinotoolkit.org/simple/wheels/nightly" ---pre -openvino==2026.1.* +optimum-intel@git+https://github.com/huggingface/optimum-intel.git numpy<2.0 -transformers>=4.54,<4.58 +transformers<5.1 pillow==12.2.0 torch==2.8.0+cpu +requests==2.33.0 From f2b0726ef5bfd0230dfc03abeeee340e7089b4c0 Mon Sep 17 00:00:00 2001 From: rasapala Date: Thu, 7 May 2026 11:04:32 +0200 Subject: [PATCH 2/5] Revert "Quick fix" This reverts commit b3388df649aab3186bf0a88cd0c58592cacc9013. --- .gitignore | 1 - .../download_model.py | 45 ++++++++++++------- .../download_model_requirements.txt | 7 +-- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index c404eb8cb8..cd26093dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,3 @@ tmp/ *.tar.gz models genhtml -.github/skills/ diff --git a/demos/python_demos/clip_image_classification/download_model.py b/demos/python_demos/clip_image_classification/download_model.py index e3bd257896..aa2a3bd852 100644 --- a/demos/python_demos/clip_image_classification/download_model.py +++ b/demos/python_demos/clip_image_classification/download_model.py @@ -14,26 +14,39 @@ # limitations under the License. #***************************************************************************** -from optimum.intel import OVModelForZeroShotImageClassification +from transformers import CLIPProcessor, CLIPModel +from PIL import Image +import openvino as ov import os model_id = "openai/clip-vit-base-patch16" -model_path = "model/1" +print(f'Downloading pretrained model {model_id} ...') + +model = CLIPModel.from_pretrained(model_id) +processor = CLIPProcessor.from_pretrained(model_id) -print(f"Exporting {model_id} to OpenVINO IR via optimum-intel ...") -ov_model = OVModelForZeroShotImageClassification.from_pretrained(model_id, export=True) +# create OpenVINO core object instance +core = ov.Core() +model.config.torchscript = True +input_labels = ['cat', 'dog', 'wolf', 'tiger', 'man', 'horse', 'frog', 'tree', 'house', 'computer'] +text_descriptions = [f"This is a photo of a {label}" for label in input_labels] +image = Image.new('RGB', (800, 600)) +model_inputs = processor(text=text_descriptions, images=[image], return_tensors="pt", padding=True) -os.makedirs(model_path, exist_ok=True) -ov_model.save_pretrained(model_path) +print(f'Converting pretrained model {model_id} ...') +ov_model = ov.convert_model(model, example_input=dict(model_inputs)) +for idx, out in enumerate(ov_model.outputs): + out.get_tensor().set_names({f"out_{idx}"}) +print(f'Saving converted model {model_id} ...') +ov.save_model(ov_model, 'clip-vit-base-patch16.xml') + +print(f'Creating OpenVINO Model Server model directories ...') +model_path = "model/1" +if not os.path.exists(model_path): + os.mkdir("model") + os.mkdir(model_path) -# OVMS expects flat .xml/.bin in the version directory. -# optimum-intel saves them as openvino_model.xml/.bin; rename to keep the existing graph.pbtxt working. -for src, dst in ( - ("openvino_model.xml", "clip-vit-base-patch16.xml"), - ("openvino_model.bin", "clip-vit-base-patch16.bin"), -): - src_path = os.path.join(model_path, src) - if os.path.exists(src_path): - os.replace(src_path, os.path.join(model_path, dst)) +os.replace("clip-vit-base-patch16.bin", os.path.join(model_path,"clip-vit-base-patch16.bin")) +os.replace("clip-vit-base-patch16.xml", os.path.join(model_path,"clip-vit-base-patch16.xml")) -print("Model ready") +print(f'Model ready') diff --git a/demos/python_demos/clip_image_classification/download_model_requirements.txt b/demos/python_demos/clip_image_classification/download_model_requirements.txt index 997a89baa9..61f27f8a64 100644 --- a/demos/python_demos/clip_image_classification/download_model_requirements.txt +++ b/demos/python_demos/clip_image_classification/download_model_requirements.txt @@ -1,7 +1,8 @@ --extra-index-url "https://download.pytorch.org/whl/cpu" -optimum-intel@git+https://github.com/huggingface/optimum-intel.git +--extra-index-url "https://storage.openvinotoolkit.org/simple/wheels/nightly" +--pre +openvino==2026.1.* numpy<2.0 -transformers<5.1 +transformers>=4.54,<4.58 pillow==12.2.0 torch==2.8.0+cpu -requests==2.33.0 From 53e3748082b802bf329f171dd92c13c21cba6b88 Mon Sep 17 00:00:00 2001 From: rasapala Date: Thu, 7 May 2026 11:07:58 +0200 Subject: [PATCH 3/5] Fix --- .gitignore | 1 + demos/python_demos/clip_image_classification/README.md | 1 + .../clip_image_classification/download_model_requirements.txt | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cd26093dfa..6e91b6c47f 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ tmp/ *.tar.gz models genhtml +.github/skills/ \ No newline at end of file diff --git a/demos/python_demos/clip_image_classification/README.md b/demos/python_demos/clip_image_classification/README.md index 9bdddefd87..e66d477055 100644 --- a/demos/python_demos/clip_image_classification/README.md +++ b/demos/python_demos/clip_image_classification/README.md @@ -24,6 +24,7 @@ pip3 install -r requirements.txt ```bash pip3 install -r download_model_requirements.txt +pip3 install transformers>=4.54,<4.58 ``` ```bash diff --git a/demos/python_demos/clip_image_classification/download_model_requirements.txt b/demos/python_demos/clip_image_classification/download_model_requirements.txt index 61f27f8a64..a6e7c55d57 100644 --- a/demos/python_demos/clip_image_classification/download_model_requirements.txt +++ b/demos/python_demos/clip_image_classification/download_model_requirements.txt @@ -3,6 +3,5 @@ --pre openvino==2026.1.* numpy<2.0 -transformers>=4.54,<4.58 pillow==12.2.0 torch==2.8.0+cpu From 6179fda27d64e71a56b0630f16ee7bf0ed071c34 Mon Sep 17 00:00:00 2001 From: rasapala Date: Thu, 7 May 2026 11:32:22 +0200 Subject: [PATCH 4/5] Fix reqs --- demos/python_demos/clip_image_classification/README.md | 3 +-- .../download_model_requirements.txt | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 demos/python_demos/clip_image_classification/download_model_requirements.txt diff --git a/demos/python_demos/clip_image_classification/README.md b/demos/python_demos/clip_image_classification/README.md index e66d477055..f82ca45576 100644 --- a/demos/python_demos/clip_image_classification/README.md +++ b/demos/python_demos/clip_image_classification/README.md @@ -23,8 +23,7 @@ pip3 install -r requirements.txt ## Download and convert model ```bash -pip3 install -r download_model_requirements.txt -pip3 install transformers>=4.54,<4.58 +pip3 install --pre --extra-index-url "https://download.pytorch.org/whl/cpu" --extra-index-url "https://storage.openvinotoolkit.org/simple/wheels/nightly" "openvino==2026.1.*" "numpy<2.0" "pillow==12.2.0" "torch==2.8.0+cpu" "transformers<=4.53.0" ``` ```bash diff --git a/demos/python_demos/clip_image_classification/download_model_requirements.txt b/demos/python_demos/clip_image_classification/download_model_requirements.txt deleted file mode 100644 index a6e7c55d57..0000000000 --- a/demos/python_demos/clip_image_classification/download_model_requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ ---extra-index-url "https://download.pytorch.org/whl/cpu" ---extra-index-url "https://storage.openvinotoolkit.org/simple/wheels/nightly" ---pre -openvino==2026.1.* -numpy<2.0 -pillow==12.2.0 -torch==2.8.0+cpu From 26db24e6ac94453d4bda97d94601c47b0fc1d11e Mon Sep 17 00:00:00 2001 From: rasapala Date: Thu, 7 May 2026 11:51:03 +0200 Subject: [PATCH 5/5] Update pygments --- src/python/binding/tests/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/binding/tests/requirements.txt b/src/python/binding/tests/requirements.txt index 6daed6ae61..e377ec380e 100644 --- a/src/python/binding/tests/requirements.txt +++ b/src/python/binding/tests/requirements.txt @@ -2,7 +2,7 @@ pytest==9.0.3 tomli==2.0.1 iniconfig==2.0.0 pluggy==1.6.0 -pygments==2.19.2 +pygments>=2.20.0 exceptiongroup==1.1.3 packaging==23.1 numpy<2