Koushik Dutta commited on
Commit
4629fa5
·
1 Parent(s): e07911a

openviono

Browse files
Files changed (1) hide show
  1. export.py +21 -1
export.py CHANGED
@@ -102,7 +102,27 @@ def convert_openvino():
102
  ov_text_model = ov.convert_model(traced_text_model, example_input=(inputs.data['input_ids'], inputs.data['attention_mask']))
103
  ov.save_model(ov_text_model, "openvino/text.xml")
104
 
105
- convert_openvino()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  # convert_coreml()
108
 
 
102
  ov_text_model = ov.convert_model(traced_text_model, example_input=(inputs.data['input_ids'], inputs.data['attention_mask']))
103
  ov.save_model(ov_text_model, "openvino/text.xml")
104
 
105
+ # convert_openvino()
106
+
107
+ def infer_openvino():
108
+ import openvino as ov
109
+ ov_vision_model = ov.Core().read_model("openvino/vision.xml")
110
+ ov_text_model = ov.Core().read_model("openvino/text.xml")
111
+
112
+ compiled_vision_model = ov.Core().compile_model(ov_vision_model, "CPU")
113
+ compiled_text_model = ov.Core().compile_model(ov_text_model, "CPU")
114
+
115
+ vision_predictions = compiled_vision_model(inputs.data['pixel_values'])
116
+ text_predictions = compiled_text_model((inputs.data['input_ids'], inputs.data['attention_mask']))
117
+
118
+ image_embeds = vision_predictions[0]
119
+ text_embeds = text_predictions[0]
120
+
121
+ logits_per_text = text_embeds @ image_embeds.T
122
+
123
+ print("similarity:", logits_per_text.item())
124
+
125
+ infer_openvino()
126
 
127
  # convert_coreml()
128