Openvino throws "RuntimeError: Cannot get dims for non static shape"
when an image is passed as numpy array
to openvino Core().compile_model()
. But the same image when passed after doing a cv2.imread()
works fine. How do we pass a numpy array
directly to openvino Core().compile_model()
?
Working code:
image = cv2.cvtColor(test_img, code=cv2.COLOR_BGR2RGB)
print("image",type(image))
print("model", compiled_model)
image = np.array(image)
# resize to MobileNet image shape
input_image = cv2.resize(src=image, dsize=(224, 224))
# reshape to network input shape
input_data = np.expand_dims(np.transpose(input_image, (0, 1, 2)), 0).astype(np.float32)
print(input_data.shape)
print("type:",type(output_layer))
# Do inference
result = compiled_model([input_data])[output_layer]
Buggy code:
for img in img_batch:
#image = cv2.cvtColor(img, code=cv2.COLOR_BGR2RGB)
resized_image = cv2.resize(src=img, dsize=(
self.node_input.input_resolution.width, self.node_input.input_resolution.height))
input_img = np.expand_dims(np.transpose(resized_image, (0, 1, 2)), 0).astype(np.float32)
res = Core().compile_model([input_img])[output_layer]
Any leads on what I am missing here is highly appreciated. Thanks in Advance !!