openvinotoolkit / openvino

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

[Failed Conversion of Tiny Yolov4 IR format into Blob file - Cannot get length of dynamic dimension] #17588

Closed Muraam-Abdel-Ghani closed 1 year ago

Muraam-Abdel-Ghani commented 1 year ago
System information (version)

yolov4-tiny-pb-format.zip

Detailed description

When I run blobconverter to convert my IR model into a blob file using the code below, I get the following error:

blob_path = blobconverter.from_openvino(
    xml="/content/yolov4-tiny.xml",
    bin="/content/yolov4-tiny.bin",
    data_type="FP16",
    shaves=6,
    version="2022.1",
    use_cache=False
)
from google.colab import files
files.download(blob_path)

Error:

Downloading /root/.cache/blobconverter/yolov4-tiny_openvino_2022.1_6shave.blob...
{
    "exit_code": 1,
    "message": "Command failed with exit code 1, command: /opt/intel/openvino2022_1/tools/compile_tool/compile_tool -m /tmp/blobconverter/6a676c91b2f043349a463c4188aab1c0/yolov4-tiny/FP16/yolov4-tiny.xml -o /tmp/blobconverter/6a676c91b2f043349a463c4188aab1c0/yolov4-tiny/FP16/yolov4-tiny.blob -c /tmp/blobconverter/6a676c91b2f043349a463c4188aab1c0/myriad_compile_config.txt -d MYRIAD -ip U8",
    "stderr": "Cannot get length of dynamic dimension\n",
    "stdout": "OpenVINO Runtime version ......... 2022.1.0\nBuild ........... 2022.1.0-7019-cdb9bec7210-releases/2022/1\nNetwork inputs:\n    inputs : u8 / [...]\nNetwork outputs:\n    output_boxes:0 : f16 / [...]\n"
}
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)

From the error message, it says: Cannot get length of dynamic dymension, and the error is coming from the Compile Tool. I also tried using the following code following the guidelines for using blobconverter and the online tool and I still get the same error. !python3 -m blobconverter -ox /content/yolov4-tiny.xml -ob /content/yolov4-tiny.bin -o /content/ -v 2022.1 --converter-url "https://blobconverter.luxonis.com/compile"

Steps to reproduce

1- Upload xml and bin files to Colab 3- Install OpenVino and OpenVino-Dev 2- Run the following:


blob_path = blobconverter.from_openvino(
    xml="/content/yolov4-tiny.xml",
    bin="/content/yolov4-tiny.bin",
    data_type="FP16",
    shaves=6,
    version="2022.1",
    use_cache=False
)
from google.colab import files
files.download(blob_path)```
avitial commented 1 year ago

@Muraam-ma1800416 the issue sounds very similar to #17531, the underlying issue is that your model contains dynamic shapes which Myriad plugin doesn't support.

Try converting the TF .pb model to IR with static shape, as shown in MO command below. Then proceed to generate the blob and see if that resolves the 'Cannot get length of dynamic dymension' issue. $ mo --input_model yolov4-tiny.pb --input_shape [1,416,416,3] --static_shape --use_new_frontend

Muraam-Abdel-Ghani commented 1 year ago

Yes the issue of Dynamic Dimension was resolved, but now I get another issue and it's still not converting to a blob file.

Error Message
Command failed with exit code 1, command: /opt/intel/openvino2022_1/tools/compile_tool/compile_tool -m /tmp/blobconverter/f5b0760caded4462a7577480d162b289/yolov4-tiny/FP16/yolov4-tiny.xml -o /tmp/blobconverter/f5b0760caded4462a7577480d162b289/yolov4-tiny/FP16/yolov4-tiny.blob -c /tmp/blobconverter/f5b0760caded4462a7577480d162b289/myriad_compile_config.txt -d MYRIAD -ip U8

Console Output
OpenVINO Runtime version ......... 2022.1.0
Build ........... 2022.1.0-7019-cdb9bec7210-releases/2022/1
Network inputs:
    inputs : u8 / [...]
Network outputs:
    output_boxes : f16 / [...]

Error Output
[ GENERAL_ERROR ]  AssertionFailed: checkStrides(child->desc(), parent->strides(), child->requiredStrides())

I tried to debug the error and searched about it but all it says is that one should use the latest OpenVino library for conversion, but I am already using OpenVino 2022.3?

avitial commented 1 year ago

@Muraam-ma1800416 I have not seen this error before so not sure what it may mean. Allow us to investigate and get back to you promptly. Can you share your model's weights file?

Ref. 111805

avitial commented 1 year ago

@Muraam-ma1800416 do you have any updates regarding our ask to share your model's weight file?

Muraam-Abdel-Ghani commented 1 year ago

Sorry for the late reply, here is the weight file: yolov4-tiny-custom_final.zip

avitial commented 1 year ago

@Muraam-ma1800416 thank you, I apologize but the .cfg file is missing could you please share that as well? I am having issues converting to .pb with .cfg file from OMZ's yolo-v4-tiny-tf model.

Muraam-Abdel-Ghani commented 1 year ago

Sure, here it is: yolov4-tiny-custom-cfg.zip

avitial commented 1 year ago

@Muraam-ma1800416 I was able to convert the model, execute on Myriad plugin and generate .blob by following the steps outlined for yolo-v4-tiny-tf in the OMZ's omz_converter tool.

Please try the steps below and check if it works for you. Note this was done in a virtualenv with OpenVINO 2022.1, as this OV version includes support for VPU plugins (Myriad/HDDL).

$ omz_downloader --name yolo-v4-tiny-tf

// replace yolov4-tiny.weights and yolov4-tiny.cfg with _yolov4-tiny-customfinal.weights and yolov4-tiny-custom.cfg.

$ cp yolov4-tiny-custom_final.weights public/yolo-v4-tiny-tf/yolov4-tiny.weights
$ cp yolov4-tiny-custom.cfg public/yolo-v4-tiny-tf/keras-YOLOv3-model-set/cfg/yolov4-tiny.cfg 

// run omz_converter tool

$ omz_converter --name yolo-v4-tiny-tf --precision FP16

// run benchmark_app with Myriad plugin and generated IR file

$ benchmark_app -m public/yolo-v4-tiny-tf/FP16/yolo-v4-tiny-tf.xml -niter 16 -d MYRIAD
...
[ INFO ] OpenVINO:
         API version............. 2022.1.0-7019-cdb9bec7210-releases/2022/1
[ INFO ] Device info
         MYRIAD
         openvino_intel_myriad_plugin version 2022.1
         Build................... 2022.1.0-7019-cdb9bec7210-releases/2022/1
...
[ INFO ] First inference took 51.17 ms
[Step 11/11] Dumping statistics report
Count:          16 iterations
Duration:       439.43 ms
Latency:
    Median:     106.47 ms
    AVG:        102.54 ms
    MIN:        59.65 ms
    MAX:        118.97 ms
Throughput: 36.41 FPS

// run compile tool with generated IR file

$ compile_tool -m public/yolo-v4-tiny-tf/FP16/yolo-v4-tiny-tf.xml -d MYRIAD -ip U8 -o yolo-v4-tiny.blob
OpenVINO Runtime version ......... 2022.1.0
Build ........... 2022.1.0-7019-cdb9bec7210-releases/2022/1
Network inputs:
    image_input : u8 / [N,H,W,C]
Network outputs:
    conv2d_17/BiasAdd:0 : f16 / [...]
    conv2d_20/BiasAdd:0 : f16 / [...]
Done. LoadNetwork time elapsed: 1824 ms
avitial commented 1 year ago

Closing this, I hope previous responses were sufficient to help you proceed. Feel free to reopen and ask additional questions related to this topic.