Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
df317c5
Created a model download + Openvino IR format conversion script, used…
Raghavyadav17 Jun 9, 2025
730d0d1
Add image embedding pipeline with model conversion, preprocessing, po…
Raghavyadav17 Jun 23, 2025
39e7126
Fix: Use numpy<2.0.0 in Dockerfile for compatibility
Raghavyadav17 Jun 23, 2025
9c3be96
Cleanup: Removed venvs and config/make.save files per mentor feedback
Raghavyadav17 Jun 24, 2025
ad2151f
Removed stray convert_clip.py from old PR (not needed)
Raghavyadav17 Jun 24, 2025
9c61416
Fix: updated MediaPipe graph based on mentor feedback
Raghavyadav17 Jun 24, 2025
df9413d
Updated files corrected under Damian's supervision in the meeting
Raghavyadav17 Jul 2, 2025
30bc6a9
Restore Dockerfile.ubuntu after accidental deletion
Raghavyadav17 Jul 2, 2025
38ad1f3
fully functional grpc client + requirements.txt
Raghavyadav17 Jul 22, 2025
f92dd9c
Conversion scripts for dino and laion models to openvino IR
Raghavyadav17 Jul 22, 2025
11c17b5
Updated pre.py
Raghavyadav17 Aug 2, 2025
d2519fa
Updated post.py
Raghavyadav17 Aug 2, 2025
012583a
updated .json file for all models and their respective mediapipe
Raghavyadav17 Aug 2, 2025
a2d7460
Final grpc script, updated clip conversion script, updated requiremen…
Raghavyadav17 Aug 27, 2025
b835e8a
Demo images folder which contains all the images required to build ve…
Raghavyadav17 Aug 27, 2025
709e1f7
mediapipe for clip model
Raghavyadav17 Aug 27, 2025
e119826
mediapipe for dino
Raghavyadav17 Aug 27, 2025
a2fd941
mediapipe for laion
Raghavyadav17 Aug 27, 2025
b0368b2
demo image
Raghavyadav17 Aug 28, 2025
629fa64
search logic
Raghavyadav17 Aug 28, 2025
12bb4a6
demo frontend
Raghavyadav17 Aug 28, 2025
57b2bc9
config json for the project
Raghavyadav17 Aug 30, 2025
8367268
readme for the project
Raghavyadav17 Aug 30, 2025
04f4a53
Final grpc script with cli argument + loading bar as discussed in the…
Raghavyadav17 Aug 30, 2025
259e4ac
demo img for testing
Raghavyadav17 Aug 30, 2025
24196cb
final dino conversion script based on copilot suggestions
Raghavyadav17 Aug 30, 2025
cfc063a
final pre.py based on copilt suggestion
Raghavyadav17 Aug 30, 2025
d1f24b4
fixed dockerfile
Raghavyadav17 Aug 30, 2025
1a5129b
Merge branch 'main' into raghav/image-embedding
Raghavyadav17 Aug 30, 2025
00c8fb2
Merge branch 'main' into raghav/image-embedding
Raghavyadav17 Sep 1, 2025
6e0f4d0
Update demos/python_demos/image_embeddings/Readme.md
Raghavyadav17 Sep 1, 2025
212485d
Update demos/python_demos/image_embeddings/Readme.md
Raghavyadav17 Sep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 0 additions & 428 deletions Dockerfile.ubuntu

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from transformers import CLIPProcessor, CLIPModel
from PIL import Image
import openvino as ov
import os

model_id="openai/clip-vit-base-patch32"
print(f"Downloading pretrained model {model_id}...")

full_model=CLIPModel.from_pretrained(model_id)
model=full_model.vision_model
processor=CLIPProcessor.from_pretrained(model_id)

image=Image.new("RGB",(224,224))
inputs=processor(images=image,return_tensors="pt")["pixel_values"]

print("Converting model...")
ov_model=ov.convert_model(model,example_input=inputs)
ov.save_model(ov_model,"clip_image_encoder.xml")
print("Model saved!")

mod_path="saved_mod/1"
os.makedirs(mod_path,exist_ok=True)
os.replace("clip_image_encoder.xml", f"{mod_path}/clip_image_encoder.xml")
os.replace("clip_image_encoder.bin", f"{mod_path}/clip_image_encoder.bin")
print("Model ready for OVMS")




15 changes: 15 additions & 0 deletions demos/python_demos/image_embeddings/servable/config_model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"model_config_list": [
{
"config": {
"name": "clip",
"base_path": "/saved_mod/"
}
}],
"mediapipe_config_list": [
{
"name": "python_model",
"graph_path": "/workspace/grph_pipeline.pbtxt"
}
]
}
72 changes: 72 additions & 0 deletions demos/python_demos/image_embeddings/servable/graph_pipeline.pbtxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
input_stream: "OVMS_PY_TENSOR:image"
output_stream: "OVMS_PY_TENSOR:embedding"

node{
name: "ImagePreprocessor"
calculator: "PythonExecutorCalculator"
input_stream: "OVMS_PY_TENSOR:image"
output_stream: "OVMS_PY_TENSOR:pixel_values"
node_options:{
[type.googleapis.com/mediapipe.PythonExecutorCalculatorOptions]:{
handler_path: "/workspace/pre.py"
}
}
}

node{
name: "PixelValuesConverter"
calculator: "PyTensorOvTensorConverterCalculator"
input_stream: "OVMS_PY_TENSOR:pixel_values"
output_stream: "OVTENSOR:40"
}

node {
calculator: "OpenVINOModelServerSessionCalculator"
output_side_packet: "SESSION:session"
node_options: {
[type.googleapis.com/mediapipe.OpenVINOModelServerSessionCalculatorOptions]: {
servable_name: "clip"
servable_version: "1"
}
}
}

node {
calculator: "OpenVINOInferenceCalculator"
input_side_packet: "SESSION:session"
input_stream: "OVTENSOR:40"
output_stream: "OVTENSOR:pooler_output"
node_options: {
[type.googleapis.com/mediapipe.OpenVINOInferenceCalculatorOptions]: {
tag_to_input_tensor_names {
key: "OVTENSOR"
value: "40"
}
tag_to_output_tensor_names {
key: "OVTENSOR"
value: "pooler_output"
}
}
}
}


node {
name: "EmbeddingConverter"
calculator: "OvTensorPyTensorConverterCalculator"
input_stream: "OVTENSOR:pooler_output"
output_stream: "OVMS_PY_TENSOR:pooler_output"
}


node {
name: "Postprocessor"
calculator: "PythonExecutorCalculator"
input_stream: "OVMS_PY_TENSOR:pooler_output"
output_stream: "OVMS_PY_TENSOR:embedding"
node_options: {
[type.googleapis.com/mediapipe.PythonExecutorCalculatorOptions]: {
handler_path: "/workspace/post.py"
}
}
}
16 changes: 16 additions & 0 deletions demos/python_demos/image_embeddings/servable/post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pyovms import Tensor
import numpy as np
from scipy.special import softmax
from tritonclient.utils import deserialize_bytes_tensor

class OvmsPythonModel:

def initialize(self, kwargs:dict):
pass

def execute(self, inputs:list):
embedding=inputs[0].as_numpy()
norm=np.linalg.norm(embedding, axis=1, keepdims=True)
normalized_embedding=embedding/norm

return[Tensor(name="embedding", data=normalized_embedding.astype(np.float32))]
20 changes: 20 additions & 0 deletions demos/python_demos/image_embeddings/servable/pre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pyovms import Tensor
from transformers import CLIPProcessor
from PIL import Image
import numpy as np
from io import BytesIO
from tritonclient.utils import deserialize_bytes_tensor

class OvmsPythonModel:
def initialize(self, kwargs:dict):
model_id="openai/clip-vit-base-patch32"
self.processor=CLIPProcessor.from_pretrained(model_id)

def execute(self,inputs: list):
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in function parameter. Should be execute(self, inputs: list).

Suggested change
def execute(self,inputs: list):
def execute(self, inputs: list):

Copilot uses AI. Check for mistakes.

image_bytes = deserialize_bytes_tensor(bytes(inputs[0]))[0]

image=Image.open(BytesIO(image_bytes)).convert("RGB")
processed=self.processor(images=image,return_tensors="np")
pixel_values=processed["pixel_values"].astype(np.float32)
return[Tensor(name="40",data=pixel_values)]