Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldnt convert to OpenVino #40

Open
osivinyuk opened this issue Apr 1, 2021 · 11 comments
Open

Couldnt convert to OpenVino #40

osivinyuk opened this issue Apr 1, 2021 · 11 comments

Comments

@osivinyuk
Copy link

python "C:\Program Files (x86)\Intel\openvino_2021\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolo_v4_tiny.json --batch 1 --reverse_input_channels Model Optimizer arguments: Common parameters: - Path to the Input Model: C:!Oleg!!!Optimization\OpenVINO-YOLOV4-master\frozen_darknet_yolov4_model.pb - Path for generated IR: C:!Oleg!!!Optimization\OpenVINO-YOLOV4-master. - IR output name: frozen_darknet_yolov4_model - Log level: ERROR - Batch: 1 - Input layers: Not specified, inherited from the model - Output layers: Not specified, inherited from the model - Input shapes: Not specified, inherited from the model - Mean values: Not specified - Scale values: Not specified - Scale factor: Not specified - Precision of IR: FP32 - Enable fusing: True - Enable grouped convolutions fusing: True - Move mean values to preprocess section: None - Reverse input channels: True TensorFlow specific parameters: - Input model in text protobuf format: False - Path to model dump for TensorBoard: None - List of shared libraries with TensorFlow custom layers implementation: None - Update the configuration file with input/output node names: None - Use configuration file used to generate the model with Object Detection API: None - Use the config file: None Model Optimizer version: 2021.2.0-1877-176bdf51370-releases/2021/2 [ WARNING ] Detected not satisfied dependencies: test-generator: installed: 0.1.2, required: == 0.1.1 Please install required versions of components or use install_prerequisites script C:\Program Files (x86)\Intel\openvino_2021\deployment_tools\model_optimizer\install_prerequisites\install_prerequisites_tf.bat Note that install_prerequisites scripts may install additional components. [ ERROR ] Exception occurred during running replacer "fusing" (<class 'extensions.middle.fusings.Fusing'>): After partial shape inference were found shape collision for node detector/cspdarknet-53/Conv/BatchNorm/FusedBatchNormV3/beta (old shape: [ 1 32 416 416], new shape: [ 1 32 416 -1])

I was trying different configurations, but couldnt convert

@TNTWEN
Copy link
Owner

TNTWEN commented Apr 2, 2021

what's your tiny model?Custom model or official yolov4tiny?

you should install all the prerequisites according to openvino

what configuration you have changed??
your .cfg,.json?

@TNTWEN
Copy link
Owner

TNTWEN commented Apr 2, 2021

And why you use yolo_v4_tiny.json but there is detector/cspdarknet-53/Conv/BatchNorm/FusedBatchNormV3/beta in your model?

@osivinyuk
Copy link
Author

Its my custom yolov4-tiny model

Here .json

[
{
"id": "TFYOLOV4",
"match_kind": "general",
"custom_attributes": {
"classes": 44,
"anchors": [30,21,61,29,58,53,95,38,122,49,92,70,142,81,283,375],
"coords": 4,
"num": 8,
"masks": [[4, 5, 6, 7], [0, 1, 2, 3]],
"entry_points": ["detector/yolo-v4-tiny/Reshape", "detector/yolo-v4-tiny/Reshape_4"]
}
}
]

I couldnt understand why detector is "detector/cspdarknet-53/Conv/BatchNorm/FusedBatchNormV3/beta"

@TNTWEN
Copy link
Owner

TNTWEN commented Apr 2, 2021

Where do you find this json file?
id and anchors masks are all wrong
i have already provide .json file and you only need to change "classes"

[
{
"id": "TFYOLOV3",
"match_kind": "general",
"custom_attributes": {
"classes": 44,
"anchors": [10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319],
"coords": 4,
"num": 6,
"masks": [[3, 4, 5], [1, 2, 3]],
"entry_points": ["detector/yolo-v4-tiny/Reshape", "detector/yolo-v4-tiny/Reshape_4"]
}
}
]

@osivinyuk
Copy link
Author

It's anchors from my .cfg file
Its my custom pretrained tiny model

@TNTWEN
Copy link
Owner

TNTWEN commented Apr 2, 2021

"id" must be "TFYOLOV3"

@osivinyuk
Copy link
Author

Its better. Trying to install prerequisites according to openvino.
Could we talk with you about some consulting - to help me convert and prune some my models for OpenVino?
My email is [email protected]
Thank you

@osivinyuk
Copy link
Author

[17. 19. 1...
[ 2021-04-02 18:37:12,875 ] [ DEBUG ] [ infer:129 ] --------------------
[ 2021-04-02 18:37:12,875 ] [ DEBUG ] [ infer:130 ] Partial infer for detector/yolo-v4-tiny/Tile/YoloRegion
[ 2021-04-02 18:37:12,875 ] [ DEBUG ] [ infer:131 ] Op: RegionYolo
[ 2021-04-02 18:37:12,875 ] [ DEBUG ] [ infer:132 ] Inputs:
[ 2021-04-02 18:37:12,876 ] [ DEBUG ] [ infer:32 ] input[0]: shape = [400 6], value = [[ 0. 0. 0. 0. 0. 0.]
[ 1. 0. 1. 0. 1. 0.]
[ 2. 0. 2. 0. 2. 0.]
...
[17. 19. 1...
[ ERROR ] Cannot infer shapes or values for node "detector/yolo-v4-tiny/Tile/YoloRegion".
[ ERROR ] index 2 is out of bounds for axis 0 with size 2
[ ERROR ]
[ ERROR ] It can happen due to bug in custom shape infer function <function RegionYoloOp.regionyolo_infer at 0x000002054E8D5550>.
[ ERROR ] Or because the node inputs have incorrect values/shapes.
[ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ 2021-04-02 18:37:12,878 ] [ DEBUG ] [ infer:197 ] Node "detector/yolo-v4-tiny/Tile/YoloRegion" attributes: {'kind': 'op', 'type': 'RegionYolo', 'op': 'RegionYolo', 'version': 'opset1', 'in_ports_count': 1, 'out_ports_count': 1, 'infer': <function RegionYoloOp.regionyolo_infer at 0x000002054E8D5550>, 'name': 'detector/yolo-v4-tiny/Tile/YoloRegion', 'axis': 1, 'end_axis': 1, 'do_softmax': 0, 'classes': 44, 'anchors': [38, 20, 60, 28, 58, 53, 92, 38, 128, 49, 92, 70, 142, 81, 283, 365], 'coords': 4, 'num': 8, 'entry_points': ['detector/yolo-v4-tiny/Reshape', 'detector/yolo-v4-tiny/Reshape_4'], 'mask': [0, 1, 2, 3], 'dim_attrs': ['channel_dims', 'spatial_dims', 'batch_dims'], 'shape_attrs': ['pad', 'output_shape', 'shape', 'window', 'stride'], 'IE': [('layer', [('id', <function Op.substitute_ie_attrs.. at 0x000002055006C8B0>), 'name', 'type', 'version'], [('data', ['coords', 'classes', 'num', 'axis', 'end_axis', ('do_softmax', <function RegionYoloOp.backend_attrs.. at 0x000002055006C940>), ('anchors', <function RegionYoloOp.backend_attrs.. at 0x000002055006C9D0>), ('mask', <function RegionYoloOp.backend_attrs.. at 0x000002055006CA60>)], []), '@ports', '@ConstS'])], '_in_ports': {0: {}}, '_out_ports': {0: {}}, 'is_output_reachable': True, 'is_undead': False, 'is_const_producer': False, 'is_partial_inferred': False}
[ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4-tiny/Tile/YoloRegion" node.
For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)
[ 2021-04-02 18:37:12,880 ] [ DEBUG ] [ main:361 ] Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\middle\passes\infer.py", line 135, in partial_infer
node.infer(node)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\extensions\ops\regionyolo.py", line 84, in regionyolo_infer
width=input_shape[get_width_dim(layout, 4)])
IndexError: index 2 is out of bounds for axis 0 with size 2

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 288, in apply_transform
replacer.find_and_replace_pattern(graph)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\extensions\middle\PartialInfer.py", line 33, in find_and_replace_pattern
partial_infer(graph)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\middle\passes\infer.py", line 198, in partial_infer
raise Error('Stopped shape/value propagation at "{}" node. '.format(node.soft_get('name')) +
mo.utils.error.Error: Stopped shape/value propagation at "detector/yolo-v4-tiny/Tile/YoloRegion" node.
For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\main.py", line 345, in main
ret_code = driver(argv)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\main.py", line 309, in driver
ret_res = emit_ir(prepare_ir(argv), argv)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\main.py", line 252, in prepare_ir
graph = unified_pipeline(argv)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\pipeline\unified.py", line 25, in unified_pipeline
class_registration.apply_replacements(graph, [
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 340, in apply_replacements
apply_replacements_list(graph, replacers_order)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 326, in apply_replacements_list
apply_transform(
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\utils\logger.py", line 124, in wrapper
function(*args, **kwargs)
File "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo\utils\class_registration.py", line 306, in apply_transform
raise Error('Exception occurred during running replacer "{}" ({}): {}'.format(
mo.utils.error.Error: Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4-tiny/Tile/YoloRegion" node.
For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)

@ghost
Copy link

ghost commented Aug 23, 2021

Hi TNTWEN
when I convert my yolov4 tiny model to IR model from tensorflow model, I got same problem.
Just only change cfg classes to 17.
RUN

python3 /opt/intel/openvino_2021/deployment_tools/model_optimizer/mo.py  --input_model models/yolov4_tiny_17.pb  --transformations_config models/yolo_v4_tiny_17.json -b 1 --output_dir models
[ ERROR ]  Cannot infer shapes or values for node "detector/yolo-v4-tiny/Tile/YoloRegion".
[ ERROR ]  index 2 is out of bounds for axis 0 with size 2
[ ERROR ]
[ ERROR ]  It can happen due to bug in custom shape infer function <function RegionYoloOp.regionyolo_infer at 0x167530dd0>.
[ ERROR ]  Or because the node inputs have incorrect values/shapes.
[ ERROR ]  Or because input shapes are incorrect (embedded to the model or passed via --input_shape).
[ ERROR ]  Run Model Optimizer with --log_level=DEBUG for more information.
[ ERROR ]  Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4-tiny/Tile/YoloRegion" node.
 For more information please refer to Model Optimizer FAQ, question #38. (https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ.html?question=38#question-38)

ENVIROMENT
macos, python3.7, tensorflow1.15.5, OpenVINO2021.4

@pranathivemuri
Copy link

@osivinyuk or @LouisDong1995 did you resolve your error? I am seeing the exact same error for yolov4 tiny model and wondering if you found a solution, thanks so much for your reply in advance

@osivinyuk
Copy link
Author

@LouisDong1995 I have sold it, but need to remember how to do it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants