Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6403 Discussions

yolov3-tiny detect wrong object when using opencv with Dnn.DNN_BACKEND_INFERENCE_ENGINE

Ji__Alex
Beginner
1,577 Views

Environment: Ubuntu 20.04 Desktop 64bit LTS

OpenVINO version:  I built openvino from openvino source code (should be 2021.2 I guess) in https://github.com/openvinotoolkit/openvino.

OpenCV version:  I built opencv 4.5.1 from source code through getting the source from https://github.com/opencv/opencv/releases

Coding language: Java

I have trained a yolo-v3-tiny weight which can detect cars on road.

When I use Dnn object in opencv to detect vehicles on road, if my backendTarget is Dnn.DNN_BACKEND_INFERENCE_ENGINE, the detection result will be wrong as below:

target-cpu--backend-inference-engine.png

However, if the backendTarget is DNN_BACKEND_OPENCV or  DNN_BACKEND_CUDA, the detection result is correct as below:

target-cpu--backend-opencv.png

 

Could anyone provide me how to fix the problem ?

Many thanks

0 Kudos
9 Replies
Adli
Moderator
1,543 Views

Hi Ji__Alex,

 

Thank you for reaching out to us. A quick check, did you convert the 'yolov3_tiny' model into intermediate representation (IR) files and load the IR files to the sample?

 

To convert a Yolo model from Tensorflow into IR, please refer to the following link:

https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html#yolov3-to-ir

 

Regards,

Adli


0 Kudos
Ji__Alex
Beginner
1,518 Views

Hi Adli,

Thanks for the suggestion.

I did visit the page you provided. But the code tensorflow-yolo-v3 seems to have some error and could not convert my yolo weights to IR. Some people met the same error as mine.

Could you provide other solutions ?

Many thanks.

0 Kudos
Adli
Moderator
1,507 Views

Hi Ji__Alex,


If possible, could you share the additional information regarding:

• Errors you got when you convert your Yolo weights to IR.

• Base model you used for retraining the Yolo model.


Regards,

Adli


0 Kudos
Ji__Alex
Beginner
1,497 Views

Environment:

  • OS: Ubuntu 16.04 64bit
  • Python version: 3.5.2
  • Tensorflow version: 1.15

 

The weights file is trained with darknet yolo by myself.  The cfg file is as below:

And I only trained my yolo to recognize 7 objects. The training images are  800x480 each

[net]
# Testing =====================
#batch=1
#subdivisions=1
# Training ====================
batch=64
subdivisions=2
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=1

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

###########

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=36
activation=linear



[yolo]
mask = 3,4,5
# anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
anchors = 15.0716,22.0683, 24.6420,38.2022, 39.4322,54.0639, 43.1956,80.2898, 71.1955,79.5135, 68.3642,123.0715, 105.2143,112.0091, 111.6479,181.4604, 124.9255,251.8264
classes=7
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 8

[convolutional]
batch_normalize=1
filters=36
size=3
stride=1
pad=1
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=36
activation=linear

[yolo]
mask = 0,1,2
#anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
anchors = 15.0716,22.0683, 24.6420,38.2022, 39.4322,54.0639, 43.1956,80.2898, 71.1955,79.5135, 68.3642,123.0715, 105.2143,112.0091, 111.6479,181.4604, 124.9255,251.8264
classes=7
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

The convert command is below:

(venv) alexji@u1604d01:~/python-projects/tensorflow-yolo-v3$ python ./convert_weights.py --class_names ~/yolo/dataset_800x480/class.names --weights_file ~/yolo/weights/yolov3-tiny-ai_43300.weights --tiny

Output is  below

WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
* https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From ./convert_weights.py:52: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

WARNING:tensorflow:From ./convert_weights.py:34: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0107 18:55:09.718114 139679257401088 module_wrapper.py:139] From ./convert_weights.py:34: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From ./convert_weights.py:36: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0107 18:55:09.719187 139679257401088 module_wrapper.py:139] From ./convert_weights.py:36: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
W0107 18:55:09.722118 139679257401088 deprecation.py:323] From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

W0107 18:55:09.956478 139679257401088 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

WARNING:tensorflow:From ./convert_weights.py:39: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

W0107 18:55:10.009059 139679257401088 module_wrapper.py:139] From ./convert_weights.py:39: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

W0107 18:55:10.015722 139679257401088 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

Traceback (most recent call last):
File "./convert_weights.py", line 52, in <module>
tf.app.run()
File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "./convert_weights.py", line 40, in main
scope='detector'), FLAGS.weights_file)
File "/home/alexji/python-projects/tensorflow-yolo-v3/utils.py", line 115, in load_weights
(shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 124868 into shape (256,384,3,3)
(venv) alexji@u1604d01:~/python-projects/tensorflow-yolo-v3$

 

However, if I trained the original weights file (https://pjreddie.com/media/files/yolov3-tiny.weights), then the result is successful.

 

By the way, does OpenVINO team consider to provide a tool to convert yolo weights to IR ? I believe that many people use darknet yolo to train the weights.

Thanks a lot.

0 Kudos
Adli
Moderator
1,490 Views

Hi Ji__Alex,

 

To convert a YOLOv3 model into the OpenVINO IR model, you need to convert the YOLOv3 model into the Tensorflow protobuf (.pb) file. Step-by-step instruction is available here. Then, OpenVINO Model Optimizer will convert the protobuf file to the IR model. To convert YOLOv3 TensorFlow Model to the IR, please refer to the following link.

 

Based on your convert command, please use 'convert_weight_pb.py' scripts. For example, refer to the following command:

python3 convert_weights_pb.py --class_names coco.names --data_format NHWC --weights_file yolov3-tiny.weights --tiny --size 608

Please note to provide the '--size' key with the size of your image specified. Feel free to reach out to us if you require any help.

 

Regards,

Adli

0 Kudos
Ji__Alex
Beginner
1,484 Views

Hi, Adli,

I followed your suggestion. The result is the same.

I know that some people have the same error for their own customized trained weights. But it seems there is no complete solution.

 

(venv) alexji@u1604d01:~/python-projects/tensorflow-yolo-v3$ python3 convert_weights_pb.py --class_names ~/yolo/dataset_800x480/class.names --data_format NHWC --weights_file ~/yolo/weights/yolov3-tiny-ai_43300.weights --tiny --size 800
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From convert_weights_pb.py:52: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

WARNING:tensorflow:From convert_weights_pb.py:38: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0108 20:33:27.534012 139870877484800 module_wrapper.py:139] From convert_weights_pb.py:38: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From convert_weights_pb.py:40: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0108 20:33:27.535260 139870877484800 module_wrapper.py:139] From convert_weights_pb.py:40: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
W0108 20:33:27.537434 139870877484800 deprecation.py:323] From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

W0108 20:33:27.765171 139870877484800 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

WARNING:tensorflow:From convert_weights_pb.py:42: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

W0108 20:33:27.813531 139870877484800 module_wrapper.py:139] From convert_weights_pb.py:42: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

W0108 20:33:27.822771 139870877484800 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

Traceback (most recent call last):
  File "convert_weights_pb.py", line 52, in <module>
    tf.app.run()
  File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/absl/app.py", line 303, in run
    _run_main(main, args)
  File "/home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "convert_weights_pb.py", line 42, in main
    load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file)
  File "/home/alexji/python-projects/tensorflow-yolo-v3/utils.py", line 115, in load_weights
    (shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 124868 into shape (256,384,3,3)
(venv) alexji@u1604d01:~/python-projects/tensorflow-yolo-v3$

 

Again, if I use the original coco.names and yolov3-tiny.weights, it works in my environment.

So, any other suggestion?

Many thanks.

 

0 Kudos
Adli
Moderator
1,472 Views

Hi Ji__Alex,

 

A quick check, which pre-trained weight did you use to train your model? Is it darknet53.conv.74 or this weight from the Yolo website? If possible, could you retrain your model using this yolov3-tiny.conv.11?

 

Regards,

Adli

 

0 Kudos
Adli
Moderator
1,436 Views

Hi Ji__Alex,

 

 Thank you for your question. If you need any additional information from Intel, please submit a new question as this thread is no longer being monitored.


Regards,

Adli


0 Kudos
Ji__Alex
Beginner
1,431 Views

Hi, Adli,

Sorry for replying late.

Well, I did followed your suggestion and re-trained my model from yolov3-tiny.conv.11.

And eventually I think it was successfully to convert the yolo weights file to .pb file, although the process of convertion appeared some warnings. I list the detail warning messages as below:

(venv) alexji@u1604d01:~/python-projects/tensorflow-yolo-v3$ python3 convert_weights_pb.py --class_names /home/alexji/yolo/dataset_800x480/class.names --data_format NHWC --weights_file /home/alexji/yolo/yolov3-tiny-2021-01_best.weights --tiny
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
* https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
* https://github.com/tensorflow/addons
* https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From convert_weights_pb.py:52: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

WARNING:tensorflow:From convert_weights_pb.py:38: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0126 08:09:28.158443 140007948916480 module_wrapper.py:139] From convert_weights_pb.py:38: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From convert_weights_pb.py:40: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0126 08:09:28.159777 140007948916480 module_wrapper.py:139] From convert_weights_pb.py:40: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
W0126 08:09:28.161724 140007948916480 deprecation.py:323] From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

W0126 08:09:28.396190 140007948916480 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/yolo_v3.py:180: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

WARNING:tensorflow:From convert_weights_pb.py:42: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

W0126 08:09:28.452056 140007948916480 module_wrapper.py:139] From convert_weights_pb.py:42: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

W0126 08:09:28.872488 140007948916480 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

WARNING:tensorflow:From convert_weights_pb.py:47: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0126 08:09:29.320442 140007948916480 module_wrapper.py:139] From convert_weights_pb.py:47: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2021-01-26 08:09:29.322690: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-01-26 08:09:29.323289: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2021-01-26 08:09:29.323337: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (u1604d01): /proc/driver/nvidia/version does not exist
2021-01-26 08:09:29.324063: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-01-26 08:09:29.339073: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3600010000 Hz
2021-01-26 08:09:29.340168: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4e7e2c0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-01-26 08:09:29.340197: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:52: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

W0126 08:09:29.860083 140007948916480 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:52: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:53: convert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.convert_variables_to_constants`
W0126 08:09:30.123280 140007948916480 deprecation.py:323] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:53: convert_variables_to_constants (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.convert_variables_to_constants`
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/python/framework/graph_util_impl.py:277: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
W0126 08:09:30.123482 140007948916480 deprecation.py:323] From /home/alexji/python-projects/tensorflow-yolo-v3/venv/lib/python3.5/site-packages/tensorflow_core/python/framework/graph_util_impl.py:277: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.compat.v1.graph_util.extract_sub_graph`
INFO:tensorflow:Froze 59 variables.
I0126 08:09:30.170844 140007948916480 graph_util_impl.py:334] Froze 59 variables.
INFO:tensorflow:Converted 59 variables to const ops.
I0126 08:09:30.360620 140007948916480 graph_util_impl.py:394] Converted 59 variables to const ops.
WARNING:tensorflow:From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:56: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

W0126 08:09:30.362571 140007948916480 module_wrapper.py:139] From /home/alexji/python-projects/tensorflow-yolo-v3/utils.py:56: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

299 ops written to frozen_darknet_yolov3_model.pb.

 

And the convert .pb file to IR files:

alexji@u2004d-mate:~/tmp$ /opt/openvino/deployment_tools/model_optimizer/mo_tf.py --input_model ./frozen_darknet_yolov3_416_model.pb --transformations_config ../yolo/yolo_v3_tiny_alex_2021-01.json --batch 1
/opt/openvino/deployment_tools/model_optimizer/mo/main.py:85: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if op is 'k':
Model Optimizer arguments:
Common parameters:
	- Path to the Input Model: 	/home/alexji/tmp/./frozen_darknet_yolov3_416_model.pb
	- Path for generated IR: 	/home/alexji/tmp/.
	- IR output name: 	frozen_darknet_yolov3_416_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: 	False
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: 	custom_master_cc019e0a11e47f635eb0dd6ba12d8d4eb94b289a
2021-01-26 08:18:45.411808: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2021-01-26 08:18:45.411847: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

[ SUCCESS ] Generated IR version 10 model.
[ SUCCESS ] XML file: /home/alexji/tmp/./frozen_darknet_yolov3_416_model.xml
[ SUCCESS ] BIN file: /home/alexji/tmp/./frozen_darknet_yolov3_416_model.bin
[ SUCCESS ] Total execution time: 8.63 seconds. 
[ SUCCESS ] Memory consumed: 501 MB. 
alexji@u2004d-mate:~/tmp$ 

 

My code of key portion is as below:

openvinoIrXmlFilename = "frozen_darknet_yolov3_416_model.xml";
openvinoIrBinFilename = "frozen_darknet_yolov3_416_model.bin";
Net net = Dnn.readNetFromModelOptimizer(openvinoIrXmlFilename, openvinoIrBinFilename);
net.setPreferableBackend(Dnn.DNN_BACKEND_INFERENCE_ENGINE);
net.setPreferableTarget(Dnn.DNN_TARGET_CPU);

 

But Dnn seemed not detect any object.

I wonder whether the detecting object of yolo and model optimizer in openvino are the same or not.

 

0 Kudos
Reply