Closed ark- closed 4 years ago
Hi @ark- thanks for reaching out. May I ask if this issue occurs with any of the available pre-trained models in OMZ? Or does this only occur with your YOLO implementation? Please help me provide the MO command used to convert to IR and if possible also the actual model files (.pb, .cfg/.weights files) if possible.
Instead of using OpenCV dnn module, by any chance have you tried using OpenVINO inference engine through IECore? Just curious if you see the same error.
Regards, Luis
May I ask if this issue occurs with any of the available pre-trained models in OMZ?
Unfortunately I have not tried. Allow me to investigate.
Or does this only occur with your YOLO implementation? Please help me provide the MO command used to convert to IR and if possible also the actual model files (.pb, .cfg/.weights files) if possible.
I did not convert it. I used as-is using the OpenCV readNetFromDarknet
function DOC LINK. This method worked fine on OpenCV4.3 and Openvino 2020.3. I could load and run my models.
Instead of using OpenCV dnn module, by any chance have you tried using OpenVINO inference engine through IECore? Just curious if you see the same error.
I haven't used IECore. Allow me to read some docs and see what I can do.
Ok so I have tried some models from the Model Zoo here (https://download.01.org/opencv/2020/openvinotoolkit/2020.4/open_model_zoo/models_bin).
dnn_net = cv2.dnn.readNet("person-detection-0106.bin", "person-detection-0106.xml", "dldt")
dnn_out_names = self.dnn_net.getUnconnectedOutLayersNames()
blob = cv2.dnn.blobFromImage(frame,
1 / 255, (416, 416), (10, 20, 30),
swapRB=True, crop=False)
dnn_net.setInput(blob)
output_blobs = self.dnn_net.forward(self.dnn_out_names)
Models tested are:
Results as follows:
Error for Person Detection 0106 (FP16):
terminate called after throwing an instance of 'InferenceEngine::details::InferenceEngineException'
what(): Check 'PartialShape::broadcast_merge_into(pshape, get_input_partial_shape(i), autob)' failed at /home/pi/openvino/ngraph/src/ngraph/node.cpp:922:
While validating node 'v1::Add Add_3000(Add_2964[0]:f16{1,256,26,26}, Interpolate_2999[0]:f16{1,256,50,84}) -> (f16{1,256,50,84})':
Argument shapes are inconsistent.
Error for Person Detection 0106 (FP32):
terminate called after throwing an instance of 'InferenceEngine::details::InferenceEngineException'
what(): Check 'PartialShape::broadcast_merge_into(pshape, get_input_partial_shape(i), autob)' failed at /home/pi/openvino/ngraph/src/ngraph/node.cpp:922:
While validating node 'v1::Add Add_3000(Add_2964[0]:f32{1,256,26,26}, Interpolate_2999[0]:f32{1,256,50,84}) -> (f32{1,256,50,84})':
Argument shapes are inconsistent.
Pedestrian Detection ADAS 0002 (FP32) didn't crash but I am only receiving really low confidences. I switched the input video size to match those listed here: https://docs.openvinotoolkit.org/2019_R1/_pedestrian_detection_adas_0002_description_pedestrian_detection_adas_0002.html
Person Detection Retail 0013 (FP32) didn't crash but again really low confidences.
I also tried it on a MobileNetSSD_deploy
from here: https://github.com/chuanqi305/MobileNet-SSD:
dnn_net = cv2.dnn.readNet("MobileNetSSD_deploy.caffemodel", "MobileNetSSD_deploy.prototxt", "caffe")
# ... same as above
Error:
terminate called after throwing an instance of 'ngraph::NodeValidationFailure'
what(): Check 'is_valid_permutation(permutation, arg_shape.rank())' failed at /home/pi/openvino/ngraph/src/ngraph/op/transpose.cpp:65:
While validating node 'v1::Transpose Transpose_181(Add_179[0]:f32{1,12,26,26}, Constant_180[0]:i64{4}) -> (dynamic?)':
Permutation AxisVector{0, 3, 3869288809, 1599426646} is not valid for input shape {1,12,26,26}
As for using IECore in Python. Do you have a link to any documentation I could use?
@ark- thanks for the information, you can find the Python API here.
I did a quick test and I see a similar error when using yolov3-tiny (.cfg and .weights) with dnn module:
what(): Check 'is_valid_permutation(permutation, arg_shape.rank())' failed at /home/pi/openvino/ngraph/src/ngraph/op/transpose.cpp:65:
While validating node 'v1::Transpose Transpose_174(Add_172[0]:f32{1,255,13,13}, Constant_173[0]:i64{4}) -> (dynamic?)':
Permutation AxisVector{0, 3, 56, 0} is not valid for input shape {1,255,13,13}.
Running the very same test on the v2020.4 for Linux* (it has OpenCV==4.4.0), it runs well so I think there could be something missing on our build process for RPI or a possible bug. I'd need to verify this and get back to you.
Also FYI if I run the same model in IR format (converted yolov3-tiny model to IR as described here) model seems to run perfectly fine on RPI+NCS2 from source built environment, thought I'd share it as it could help you in the meantime:
import cv2 as cv
net = cv.dnn.readNet('frozen_darknet_yolov3-tiny_model.xml', 'frozen_darknet_yolov3-tiny_model.bin')
net.setPreferableBackend(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE)
net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
frame = cv.imread('image.jpg')
if frame is None:
raise Exception('Image not found!')
blob = cv.dnn.blobFromImage(cv.resize(frame, (416, 416)),
1 / 255, (416, 416), (10, 20, 30), swapRB=True, crop=False)
net.setInput(blob)
out = net.forward()
# not crashing
Regards, Luis
Luis,
Thanks very much for the update and the advice about converting to IR.
I have had a go at freezing my custom model to an IR and I am having errors such as
terminate called after throwing an instance of 'InferenceEngine::details::InferenceEngineException'
what(): Check 'PartialShape::merge_into(inputs_shape_scheme, this_input_shape)' failed at /home/pi/openvino/ngraph/src/ngraph/op/concat.cpp:90:
While validating node 'v0::Concat Concat_2423(PRelu_2212[0]:f32{1,256,20,34}, Interpolate_2422[0]:f32{1,256,26,26}) -> (f32{1,512,26,26})':
Argument shapes are inconsistent; they must have the same rank, and must have equal dimension everywhere except on the concatenation axis (axis 1).
I converted to IR the pretrained yolov3 and it worked OK. I've probably missed something in the process so don't worry too much. I'll wait until it is fixed in the RPI build process.
@ark- looks like this issue has been addressed as discussed in https://github.com/opencv/opencv/issues/17954, changes from https://github.com/opencv/opencv/pull/17998 seem to fix this issue.
Also just FYI the pre-built package for Raspbian has been made available in https://download.01.org/opencv/2020/openvinotoolkit/2020.4.
Avitial, thanks for the update. Yeah tested and fixes the issue. Will close 👍
Versions
Background
I am getting issues running a Darknet Yolov3-Tiny model with the OpenCV inference engine enhanced by the Intel Neural Compute Stick 2. I use OpenCV in CPU only mode it runs fine (but of course slow as it is not accelerated) which is why I'm posting in the OpenVino repo.
The same application code and model ran fine on the following combination of versions:
The reason I want to upgrade is to leverage some of the Yolo optimisations in OpenCV 4.4.
Issue
My application is written in Python 3.7 and when calling the net.forward() I get the following error:
This looks like theres a layer that's not been implemented in ngraph but whats confusing is that this worked fine in Openvino 2020.3.
Reproduce
This is being built on target. i.e. on the Raspberry Pi 4.
opencv
andopenvino
are in$HOME
apt-get
all prerequisitesThe python script simplified is