-
Notifications
You must be signed in to change notification settings - Fork 218
Raghav/image embedding #3429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Raghav/image embedding #3429
Changes from 21 commits
df317c5
730d0d1
39e7126
9c3be96
ad2151f
9c61416
df9413d
30bc6a9
38ad1f3
f92dd9c
11c17b5
d2519fa
012583a
a2d7460
b835e8a
709e1f7
e119826
a2fd941
b0368b2
629fa64
12bb4a6
57b2bc9
8367268
04f4a53
259e4ac
24196cb
cfc063a
d1f24b4
1a5129b
00c8fb2
6e0f4d0
212485d
0aeb55e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
import sys | ||
sys.path.append("../../common/python") | ||
import tritonclient.grpc as grpcclient | ||
from tritonclient.grpc import service_pb2 | ||
from tritonclient.grpc import service_pb2_grpc | ||
|
||
import numpy as np | ||
import os | ||
import grpc | ||
import time | ||
import json | ||
from qdrant_client import QdrantClient | ||
from qdrant_client.http import models as rest | ||
|
||
# ------------------------ Settings ------------------------ | ||
IMAGE_FOLDER = "./demo_images" | ||
QDRANT_COLLECTION = "image_embeddings" | ||
MODEL_CONFIG_FILE = "./selected_model.json" # New: Save model choice | ||
|
||
|
||
def setup_grpc_client(): | ||
"""Setup GRPC client and wait for server ready""" | ||
url = "localhost:9000" | ||
client = grpcclient.InferenceServerClient(url) | ||
channel = grpc.insecure_channel(url) | ||
grpc_stub = service_pb2_grpc.GRPCInferenceServiceStub(channel) | ||
|
||
# Wait for server ready | ||
timeout = 15 | ||
while timeout: | ||
request = service_pb2.ServerReadyRequest() | ||
response = grpc_stub.ServerReady(request) | ||
print("Server Ready: {}".format(response.ready)) | ||
if response.ready: | ||
break | ||
time.sleep(1) | ||
timeout -= 1 | ||
|
||
if not response.ready: | ||
print("Models are not ready. Increase timeout or check server setup.") | ||
exit(-1) | ||
|
||
return client | ||
|
||
|
||
def select_model(): | ||
"""Interactive model selection""" | ||
available_models = ["clip_graph", "dino_graph", "laion_graph"] | ||
print("\nSelect a model to use:") | ||
for i, model in enumerate(available_models): | ||
print(f"{i + 1}. {model}") | ||
|
||
while True: | ||
try: | ||
choice = int(input("Enter the number corresponding to the model: ")) | ||
if 1 <= choice <= len(available_models): | ||
selected_model = available_models[choice - 1] | ||
break | ||
else: | ||
print("Invalid choice.") | ||
except ValueError: | ||
print("Invalid input.") | ||
|
||
print(f"\nYou selected: {selected_model}") | ||
|
||
# Save model selection | ||
with open(MODEL_CONFIG_FILE, 'w') as f: | ||
json.dump({"selected_model": selected_model}, f) | ||
print(f"Saved model selection: {selected_model}") | ||
|
||
return selected_model | ||
|
||
|
||
def build_database(client, selected_model): | ||
"""Build/Update the image database""" | ||
qdrant = QdrantClient("localhost", port=6333) | ||
vector_size = None | ||
inference_times = [] # Track per-image inference times | ||
total_start = time.perf_counter() # For total time | ||
|
||
# Create collection if not exists | ||
if not qdrant.collection_exists(QDRANT_COLLECTION): | ||
print(f"Creating Qdrant collection: {QDRANT_COLLECTION}") | ||
|
||
# Process all images in demo folder | ||
image_files = [f for f in os.listdir(IMAGE_FOLDER) if f.lower().endswith((".jpg", ".jpeg", ".png"))] | ||
print(f"\nFound {len(image_files)} images in '{IMAGE_FOLDER}'") | ||
|
||
points = [] | ||
|
||
for idx, img_name in enumerate(image_files): | ||
img_path = os.path.join(IMAGE_FOLDER, img_name) | ||
with open(img_path, "rb") as f: | ||
image_data = f.read() | ||
|
||
image_np = np.array([image_data], dtype=np.object_) | ||
image_input = grpcclient.InferInput("image", [1], "BYTES") | ||
image_input.set_data_from_numpy(image_np) | ||
|
||
# --- measure inference time --- | ||
start_time = time.perf_counter() | ||
results = client.infer(selected_model, [image_input]) | ||
end_time = time.perf_counter() | ||
elapsed_ms = (end_time - start_time) * 1000 | ||
inference_times.append(elapsed_ms) | ||
# -------------------------------- | ||
|
||
embedding = results.as_numpy('embedding')[0] | ||
|
||
if vector_size is None: | ||
vector_size = embedding.shape[0] | ||
if not qdrant.collection_exists(QDRANT_COLLECTION): | ||
qdrant.create_collection( | ||
collection_name=QDRANT_COLLECTION, | ||
vectors_config=rest.VectorParams(size=vector_size, distance=rest.Distance.COSINE) | ||
) | ||
|
||
points.append( | ||
rest.PointStruct( | ||
id=idx, | ||
vector=embedding.tolist(), | ||
payload={"filename": img_name} | ||
) | ||
) | ||
|
||
# Upload to Qdrant | ||
if points: | ||
qdrant.upsert( | ||
collection_name=QDRANT_COLLECTION, | ||
points=points | ||
) | ||
|
||
total_end = time.perf_counter() | ||
total_time = total_end - total_start | ||
avg_time = sum(inference_times) / len(inference_times) if inference_times else 0 | ||
throughput = len(inference_times) / total_time if total_time > 0 else 0 | ||
|
||
print(f"\nInserted {len(points)} embeddings into Qdrant collection '{QDRANT_COLLECTION}'") | ||
print(f"Avg Inference Time: {avg_time:.2f} ms") | ||
print(f"Total Processing Time: {total_time:.2f} s") | ||
print(f"Throughput: {throughput:.2f} images/sec") | ||
|
||
return len(points) | ||
|
||
|
||
def main(): | ||
print("Building Image Database") | ||
print("=" * 50) | ||
|
||
try: | ||
# Setup | ||
client = setup_grpc_client() | ||
selected_model = select_model() | ||
|
||
# Build database | ||
count = build_database(client, selected_model) | ||
|
||
print(f"\nDatabase built successfully!") | ||
print(f"Total images processed: {count}") | ||
print(f"Model saved for future searches: {selected_model}") | ||
|
||
except Exception as e: | ||
print(f"Error: {str(e)}") | ||
import traceback | ||
traceback.print_exc() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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/clip/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") |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from transformers import AutoImageProcessor, AutoModel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from PIL import Image | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import openvino as ov | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
model_id="facebook/dinov2-base" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print(f"Downloading pretrained model {model_id}...") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
model=AutoModel.from_pretrained(model_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
processor=AutoImageProcessor.from_pretrained(model_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image=Image.new("RGB",(224,224)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
inputs=processor(images=image,return_tensors="pt")["pixel_values"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print("Converting models...") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ov_model=ov.convert_model(model,example_input=inputs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ov.save_model(ov_model,"dino_image_encoder.xml") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print("Model saved!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mod_path="saved_mod/dino/1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os.makedirs(mod_path,exist_ok=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces around assignment operators and after commas throughout the file. Should follow PEP 8 spacing conventions.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces around assignment operators and after commas throughout the file. Should follow PEP 8 spacing conventions.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces around assignment operators and after commas throughout the file. Should follow PEP 8 spacing conventions.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces around assignment operators and after commas throughout the file. Should follow PEP 8 spacing conventions.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing spaces around assignment operators and after commas throughout the file. Should follow PEP 8 spacing conventions.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os.replace("dino_image_encoder.xml", f"{mod_path}/dino_image_encoder.xml") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os.replace("dino_image_encoder.bin", f"{mod_path}/dino_image_encoder.bin") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
print("Model ready for OVMS") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from transformers import CLIPProcessor, CLIPModel | ||
from PIL import Image | ||
import openvino as ov | ||
import torch | ||
import os | ||
|
||
# Replace this with your LAION model | ||
model_id = "laion/CLIP-ViT-B-32-laion2B-s34B-b79K" | ||
print(f"Downloading pretrained model: {model_id}") | ||
|
||
# Load processor and model | ||
processor = CLIPProcessor.from_pretrained(model_id) | ||
full_model = CLIPModel.from_pretrained(model_id) | ||
image_encoder = full_model.vision_model | ||
image_encoder.eval() | ||
|
||
# Dummy image input for tracing | ||
image = Image.new("RGB", (224, 224)) | ||
inputs = processor(images=image, return_tensors="pt")["pixel_values"] | ||
|
||
# Convert to OpenVINO IR | ||
print("Converting image encoder to OpenVINO IR...") | ||
ov_model = ov.convert_model(image_encoder, example_input=inputs) | ||
ov.save_model(ov_model, "clip_image_encoder.xml") | ||
print("Model saved!") | ||
|
||
# Move to proper OVMS path | ||
mod_path = "saved_mod/laion/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(f"Model ready at {mod_path} for OpenVINO Model Server") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
tritonclient[all]==2.51.0 | ||
numpy<2.0.0 | ||
--extra-index-url "https://download.pytorch.org/whl/cpu" | ||
--extra-index-url "https://storage.openvinotoolkit.org/simple/wheels/nightly" | ||
--pre | ||
openvino==2025.2.* | ||
numpy<2.0 | ||
transformers<4.52 | ||
pillow==10.3.0 | ||
torch==2.7.0+cpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't edit Dockerfile.ubuntu in this pull request (this makes conflicts and is really not required)