openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
7.18k stars 2.24k forks source link

How to change output of models? #18725

Closed Bombex closed 1 year ago

Bombex commented 1 year ago

Sorry. But I can't find this information. I need convert SCRFD face detector model from onnx to openvino. I'm convert it with code below:

from openvino.tools import mo
from openvino.runtime import serialize

if not ir_path.exists():
    print("Exporting ONNX model to IR... This may take a few minutes.")
    ov_model = mo.convert_model(onnx_path, input_shape=[1,3,640,640])
    serialize(ov_model, 'scrfd_2.5g_bnkps.xml')
else:
    print(f"IR model {ir_path} already exists.")`

And when I compile my model I get the following results:

from openvino.runtime import Core
ie = Core()
model = ie.read_model("scrfd_2.5g_bnkps.xml")
compiled_model = ie.compile_model(model=model, device_name="CPU")
input_layer = compiled_model.input(0)
output_layer = compiled_model.outputs

[<Output: names[score_8] shape[1,12800,1] type: f32>,
 <Output: names[score_16] shape[1,3200,1] type: f32>,
 <Output: names[score_32] shape[1,800,1] type: f32>,
 <Output: names[bbox_8] shape[1,12800,4] type: f32>,
 <Output: names[bbox_16] shape[1,3200,4] type: f32>,
 <Output: names[bbox_32] shape[1,800,4] type: f32>,
 <Output: names[kps_8] shape[1,12800,10] type: f32>,
 <Output: names[kps_16] shape[1,3200,10] type: f32>,
 <Output: names[kps_32] shape[1,800,10] type: f32>]

How to remove the first dimension in each output layer? Because I need dimensions like [12800,1]

Bombex commented 1 year ago

I found how to change