GithubHelp home page GithubHelp logo

tntwen / openvino-yolov4 Goto Github PK

View Code? Open in Web Editor NEW
240.0 10.0 66.0 48.03 MB

This is implementation of YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l,Scaled-YOLOv4 and INT8 Quantization in OpenVINO2021.3

License: MIT License

Python 92.99% CMake 0.57% C++ 6.44%
openvino yolov4 yolov4-relu yolov4-tiny tensorflow yolov4-tiny-3l scaledyolov4

openvino-yolov4's Introduction

I'm Tianwen. 

Tianwen WU's github stats

openvino-yolov4's People

Contributors

tntwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openvino-yolov4's Issues

How to use yolo_tiny to make INT8 Quantization?

I make some changes in yolov4_416x416_qtz.json and accuracy_checker\adapters\yolo.py as follows:
"type": "yolo_v3",
"anchors": "10.0, 14.0, 23.0, 27.0, 37.0, 58.0, 81.0, 82.0, 135.0, 169.0, 344.0, 319.0",
"classes": 2,
"coords": 4,
"num": 6,
"threshold": 0.001,
"anchor_masks": [ [3, 4, 5], [1, 2, 3]],
"outputs": ["detector/yolo-v4/Conv_1/BiasAdd/YoloRegion", "detector/yolo-v4/Conv_9/BiasAdd/YoloRegion"]
and
class YoloV3Adapter(Adapter):
'anchors': default='tiny_yolo_v3',
'cells': ListField default=[13, 26],

But I got the error :
Traceback (most recent call last):
File "D:\python3.6.5\Scripts\pot-script.py", line 33, in
sys.exit(load_entry_point('pot==1.0', 'console_scripts', 'pot')())
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\app\run.py", line 37, in main
app(sys.argv[1:])
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\app\run.py", line 56, in app
metrics = optimize(config)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\app\run.py", line 123, in optimize
compressed_model = pipeline.run(model)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\pipeline\pipeline.py", line 57, in run
result = self.collect_statistics_and_run(model, current_algo_seq)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\pipeline\pipeline.py", line 67, in collect_statistics_and_run
model = algo.run(model)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\algorithms\quantization\default\algorithm.py", line 93, in run
self.algorithms[1].algo_collector.compute_statistics(model)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\statistics\collector.py", line 73, in compute_statistics
, stats = self._engine.predict(combined_stats, sampler)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\engines\ac_engine.py", line 169, in predict
stdout_redirect(self._model_evaluator.process_dataset_async, **args)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\compression\utils\logger.py", line 132, in stdout_redirect
res = fn(*args, **kwargs)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\evaluators\quantization_model_evaluator.py", line 153, in process_dataset_async
batch_raw_predictions, batch_identifiers, batch_meta
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\evaluators\quantization_model_evaluator.py", line 99, in _process_ready_predictions
return self.adapter.process(batch_raw_predictions, batch_identifiers, batch_meta)
File "C:\Intel\openvino_2021.3.394\deployment_tools\tools\post_training_optimization_toolkit\libs\open_model_zoo\tools\accuracy_checker\accuracy_checker\adapters\yolo.py", line 393, in process
predictions[b].append(raw_outputs[blob][b])
KeyError: 'detector/yolo-v4/Conv_1/BiasAdd/YoloRegion'

How to run inference with image that is not square-shaped?

In yolov4-inference-demo.py, it assumes the height and width of the image are equal.
How should I change the code to perform inference on image that is not square?

The figure below shows the part that throws error when doing inference with rectangular image.
It defines idx based on int(resized_image_w/out_blob_w) and int(resized_image_h/out_blob_h), which are equal.
How should I change this part when, for example image size is 1080x1920?

image

FPS of YoloV4 tiny is slower than Yolo3 tiny

@TNTWEN , thanks for the great work. I was able to convert and run the yolov4 tiny using the object_detection_demo_yolov3_async demo program. I've noticed that this new model is 10fps slower than yolov3 tiny. Then I realized the model is using data type FP32 vs FP16 in yolov3 tiny ( file size: 23MB vs 16.8MB). Is there a way to convert it to FP16? Thanks.

Question about file yolo_v4_tiny.json ?

Hello,

I very appreciate your excellent work. Now I want to train the yolo_v4 on my custom dataset but I don't know how to get the json file for the step convert to openvino like you did. Can you show me the way to get file "yolo_v4_tiny.json" by your file "yolo-tiny.weights" ? Thank you in advance.

Best regards

Got error white coverting to IR using mo.py

I downloaded yolo-v4-tiny.weights and converted to pb using provided script. But got error in the next step:-

Model Optimizer version:
[ ERROR ] Exception occurred during running replacer "TFYOLOV3" (<class 'extensions.front.YOLO.YoloV3RegionAddon'>): TensorFlow YOLO V3 conversion mechanism was enabled. Entry points "detector/yolo-v4/Reshape, detector/yolo-v4/Reshape_4, detector/yolo-v4/Reshape_8" were provided in the configuration file. Entry points are nodes that feed YOLO Region layers. Node with name detector/yolo-v4/Reshape doesn't exist in the graph. Refer to documentation about converting YOLO models for more information.

Please help

Perfromance degradation issue

I am getting less performance after conversion. Have you bench mark your code with before conversion and after conversion?

Issue when I run python object_detection_demo_yolov3_async.py

I've converted my custom data on the YoloV4 model it's worked. but when I run python object_detection_demo_yolov3_async.py I got this error

[ INFO ] Creating Inference Engine...
[ INFO ] Loading network
[ INFO ] Preparing inputs
[ INFO ] Loading model to the plugin
[ INFO ] Starting inference...
To close the application, press 'CTRL+C' here or switch to the output window and press ESC key
To switch between min_latency/user_specified modes, press TAB key in the output window
Traceback (most recent call last):
File "object_detection_demo_yolov3_async.py", line 518, in
sys.exit(main() or 0)
File "object_detection_demo_yolov3_async.py", line 398, in main
args.keep_aspect_ratio)
File "object_detection_demo_yolov3_async.py", line 233, in get_objects
out_blob = out_blob.buffer.reshape(net.layers[net.layers[layer_name].parents[0]].out_data[0].shape)
ValueError: cannot reshape array of size 689520 into shape (1,21,52,52)

I used image size when I'm training is 416x416x3

Thank you

Why the model quantification acceleration is not obvious ?

Before deploying with openvino, it took about 26s for 300 images ,。

After deployment, the time was significantly increased to 12s, although not the same test code was used .

But after the quantification to int8 , the time was shortened to 9.2s, and the effect was not very obvious. What may be the cause? Is there any way to improve it? Thanks.

我识别的结果都是label:0.99xx这样

按你的流程走下来都是正常,就是最后跑demo的时候,识别的结果都是显示label 而不是具体的目标名称,请问可能是什么问题?

cannot reshape array

Hi,

I'm trying to convert darknet weights into pb model, but I got this error on reshaping array.

I tried yolov4-tiny.weights and coco.names

Traceback (most recent call last):
File "convert_weights_pb.py", line 52, in
tf.app.run()
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\Users\Asus\Anaconda3\envs\env-openvino\lib\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 "D:\ds\prosa\OpenVINO-YOLOV4\utils.py", line 117, in load_weights
(shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 554878 into shape (256,256,3,3)

I also got same error on reshaping array, when converting 1 class darknet weights model into pb model.

Would you help me what's going wrong? Thanks

yolov3 tiny prn with ncs2

Hey, awesome work.
yolov4 tiny works fine on ncs2.

i tried to deploy yolov3 tiny prn on ncs2 and get split.1 error.
So i saw your post on openvino github but i don't understund how you solved the problem.

I don't know how and where to change split operation to slice operation.

When i use the benchmarkapp my model works fine. When i inference an image i get now 3 outputs [(1,18,19,19),(1,18,38,38),(1,128,38,38) for the split part) instead of 2 [(1,128,19,19),(1,128,38,38).
Typically i pass these outputs to parse_yolo_region with yoloparams. But what to do with these new outputs?

Any tips on how to change split to slice or how to work with the new outputs?
I would really appreciate your help

AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers'

object_detection_demo_yolov3_async.py this file does not support the latest version of openvino, can you update it?
I think the official website uses nGraph instead of openvino.inference_engine.ie_api.IENetwork.layers.

 File "object_detection_demo_yolov3_async.py", line 233, in get_objects                                
 out_blob = out_blob.buffer.reshape(net.layers[net.layers[layer_name].parents[0]].out_data[0].shape)
AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'layers'

YoloV4 broken with OpenVINO 2021.X

Hi @TNTWEN , I am getting an error while converting YoloV4 weight to OPENVINO format. I have tried the 2021.1 and 2021.3 version. I can replicate the issue on both versions.
It will be a great help if you can guide me on this.

(env) C:\Users\<user>\conversion\OpenVINOModelConversion>python convert_weights_pb.py --class_names cfg/coco_chip.names --weights_file ChipstackTrainedModel/custom-yolov4-detector_last.weights --data_format NHWC


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.

W0526 19:08:50.889183 16784 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.

W0526 19:08:51.322626 16784 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 C:\Users\sandeep.mohanadasan.SG\.conda\envs\openvino\lib\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.
W0526 19:08:51.344624 16784 deprecation.py:323] From C:\Users\sandeep.mohanadasan.SG\.conda\envs\openvino\lib\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 C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\yolo_v4.py:111: The name tf.image.resize_nearest_neighbor is deprecated. Please use tf.compat.v1.image.resize_nearest_neighbor instead.

W0526 19:08:53.571855 16784 module_wrapper.py:139] From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\yolo_v4.py:111: 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.

W0526 19:08:54.875165 16784 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 C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\utils.py:93: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

W0526 19:08:56.247044 16784 module_wrapper.py:139] From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\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.

W0526 19:08:57.728939 16784 module_wrapper.py:139] From convert_weights_pb.py:47: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

2021-05-26 19:08:57.806688: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\utils.py:52: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

W0526 19:09:07.070686 16784 module_wrapper.py:139] From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\utils.py:52: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

WARNING:tensorflow:From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\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`
W0526 19:09:08.241832 16784 deprecation.py:323] From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\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 C:\Users\sandeep.mohanadasan.SG\.conda\envs\openvino\lib\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`
W0526 19:09:08.251964 16784 deprecation.py:323] From C:\Users\sandeep.mohanadasan.SG\.conda\envs\openvino\lib\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 541 variables.
I0526 19:09:09.357801 16784 graph_util_impl.py:334] Froze 541 variables.
INFO:tensorflow:Converted 541 variables to const ops.
I0526 19:09:09.744303 16784 graph_util_impl.py:394] Converted 541 variables to const ops.
WARNING:tensorflow:From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\utils.py:56: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

W0526 19:09:09.807855 16784 module_wrapper.py:139] From C:\Users\sandeep.mohanadasan.SG\conversion\OpenVINOModelConversion\utils.py:56: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.

1808 ops written to frozen_darknet_yolov4_model.pb.

Intel Driver details

image

Packages List

# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
_tflow_select=2.2.0=eigen
absl-py=0.12.0=py36haa95532_0
aiohttp=3.7.4=py36h2bbff1b_1
astor=0.8.1=py36haa95532_0
astunparse=1.6.3=pypi_0
async-timeout=3.0.1=py36haa95532_0
attrs=21.2.0=pyhd3eb1b0_0
blas=1.0=mkl
bleach=1.5.0=pypi_0
blinker=1.4=py36haa95532_0
brotlipy=0.7.0=py36h2bbff1b_1003
ca-certificates=2020.12.5=h5b45459_0
cached-property=1.5.2=pypi_0
cachetools=4.2.2=pyhd3eb1b0_0
certifi=2020.12.5=py36ha15d459_1
cffi=1.14.5=py36hcd4344a_0
chardet=3.0.4=py36haa95532_1003
click=8.0.1=pyhd3eb1b0_0
cmake=3.13.0=pypi_0
coverage=5.5=py36h2bbff1b_2
cryptography=3.4.7=py36h71e12ea_0
cython=0.29.23=py36hd77b12b_0
flatbuffers=1.12=pypi_0
gast=0.2.2=pypi_0
google-auth=1.30.0=pyhd3eb1b0_0
google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
google-pasta=0.2.0=py_0
grpcio=1.34.1=pypi_0
h5py=2.10.0=py36h5e291fa_0
hdf5=1.10.4=h7ebc959_0
html5lib=0.9999999=pypi_0
icc_rt=2019.0.0=h0cc432a_1
idna=2.10=pyhd3eb1b0_0
idna_ssl=1.1.0=py36haa95532_0
importlib-metadata=3.10.0=py36haa95532_0
intel-openmp=2021.2.0=haa95532_616
keras-applications=1.0.8=py_1
keras-nightly=2.5.0.dev2021032900=pypi_0
keras-preprocessing=1.1.2=pyhd3eb1b0_0
libprotobuf=3.14.0=h23ce68f_0
markdown=3.3.4=py36haa95532_0
mkl=2020.2=256
mkl-service=2.3.0=py36h196d8e1_0
mkl_fft=1.3.0=py36h46781fe_0
mkl_random=1.1.1=py36h47e9c7a_0
multidict=5.1.0=py36h2bbff1b_2
numpy=1.18.5=pypi_0
oauthlib=3.1.0=py_0
openssl=1.1.1k=h8ffe710_0
opt_einsum=3.3.0=pyhd3eb1b0_1
pillow=8.2.0=pypi_0
pip=21.1.1=py36haa95532_0
protobuf=3.14.0=py36hd77b12b_1
pyasn1=0.4.8=py_0
pyasn1-modules=0.2.8=py_0
pycparser=2.20=py_2
pyjwt=1.7.1=py36_0
pyopenssl=20.0.1=pyhd3eb1b0_1
pyreadline=2.1=py36_1
pysocks=1.7.1=py36haa95532_0
python=3.6.5=h0c2934d_0
python_abi=3.6=1_cp36m
requests=2.25.1=pyhd3eb1b0_0
requests-oauthlib=1.3.0=py_0
rsa=4.7.2=pyhd3eb1b0_1
scipy=1.5.2=py36h9439919_0
setuptools=52.0.0=py36haa95532_0
six=1.15.0=py36haa95532_0
tensorboard=1.15.0=pypi_0
tensorboard-data-server=0.6.1=pypi_0
tensorboard-plugin-wit=1.6.0=py_0
tensorflow=1.15.5=pypi_0
tensorflow-estimator=1.15.1=pyh2649769_0
tensorflow-tensorboard=1.5.1=pypi_0
termcolor=1.1.0=py36haa95532_1
typing-extensions=3.7.4.3=hd3eb1b0_0
typing_extensions=3.7.4.3=pyh06a4308_0
urllib3=1.26.4=pyhd3eb1b0_0
vc=14.2=h21ff451_1
vs2015_runtime=14.27.29016=h5e58377_2
werkzeug=0.16.1=py_0
wheel=0.36.2=pyhd3eb1b0_0
win_inet_pton=1.1.0=py36haa95532_0
wincertstore=0.2=py36h7fe50ca_0
wrapt=1.12.1=py36he774522_1
yarl=1.6.3=py36h2bbff1b_0
zipp=3.4.1=pyhd3eb1b0_0
zlib=1.2.11=h62dcd97_4

The running of openvino+HDDL-R8 is slower than i3

I am Kman.When i use the HDDL-R8 accelerator card to run the official demo.The fps are very low,and it showed a very low "util%". My hardware configuration is as follows:

CPU: i3-8145UE
Vision Accelerator Card: hddl-R8
OS: Ubuntu18.04
OpenVINO:2020.4

Have you met this situation?

YoloV4 broken with OpenVINO 2021.1

Hello,

It seems OpenVINO 2021.1 has broken the full yolov4 converted from this tool. The tiny model is still ok. Anyone find similar result?

FAQ summary

1、


[ ERROR ] List of operations that cannot be converted to Inference Engine IR:
........................
[ ERROR ] Part of the nodes was not converted to IR. Stopped.

Be sure to install OpenVINO2020R4!!!

2、 Any reshape array error

  • Make sure .names file , JSON file's "classes" are correct
  • Make sure you train your YOLO model correctly
  • If you want to use yolov4-tiny, don‘t forget --tiny when running convert_weights_pb.py

3、How to set image size?
Default image size is 416*416
For example,if you want to use 608*608
python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4.weights --data_format NHWC --size 608

4、 Can i set different height and width?
If you want to use 640*480 remember to change this line

inputs = tf.placeholder(tf.float32, [None, FLAGS.size, FLAGS.size, 3], "inputs")

to inputs = tf.placeholder(tf.float32, [None, 640, 480, 3], "inputs")
and run python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4.weights --data_format NHWC

5、How to use custom model?
(1) When running convert_weights_pb.py use your .names file

(2) Modify "classes" in yolov4.json

6、why mo.py use --reverse_input_channels?
Darknet:pjreddie/darknet#427
Tensorflow(my project is based on mystic123 Tensorflow YOLOV3):mystic123/tensorflow-yolo-v3#2
OpenVINO OpenCV :BGR

7、YOLOV4 .weights download

yolov4
yolov4tiny

8、

"id": "TFYOLOV3",

why id is still TFYOLOV3?
If we change TFYOLOV3 to TFYOLOV4,errors will happen when running the demo.Like this:
Traceback (most recent call last): File "object_detection_demo_yolov3_async.py", line 518, in sys.exit(main() or 0) File "object_detection_demo_yolov3_async.py", line 398, in main args.keep_aspect_ratio) File "object_detection_demo_yolov3_async.py", line 233, in get_objects out_blob = out_blob.buffer.reshape(net.layers[net.layers[layer_name].parents[0]].out_data[0].shape) ValueError: cannot reshape array of size 460275 into shape (1,5415,4)
Anyone who knows how to solve this problem could communicate with me

9、C++ demo?
i have provided python demo.But you also could use this repos to convert model and run on C++ demo.

10、FP32 ,FP16
The default precision is FP32,if you want to use FP16 ,add --data_type FP16 when you run mo.py

11、OpenVINO version
All the inference devices are running normally in OpenVINO2020.4 and 2021.3
But GPU devices have bugs in the new version OpenVINO2021.1,2021.2 which has already been fixed in OpenVINO2021.3
openvinotoolkit/openvino#2925

If you want to use newer OpenVINO version:

  • Use the tensorflow1.x version required when installing OpenVINO
  • This repository provides python inference demo for different OpenVINO version.pythondemo.Choose the right demo before you run object_detection_demo_yolov3_async.py
  • You could also use C++ inference demo provided by OpenVINO.(For example,OpenVINO2021.3 default C++ demo path::C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\open_model_zoo\demos\multi_channel_object_detection_demo_yolov3\cpp))

Low FPS in YoloV4 - OpenVINO model

Hi, I have trained the YOLOV4 custom model with 3 classes. In order to improve the video inference timing (High FPS), I have optimized it with OpenVINO. However, the inference timing is not improved (got around 3FPS). Any suggestion to improve the timing?.
The command used for inference:
python object_detection_demo_yolov3_async.py -i video.mp4 -m frozen_darknet_yolov4_model_weapon.xml -d CPU

For model optimization:
python "C:\Program Files (x86)\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1 --reverse_input_channels

yolov4.josn:
[
{
"id": "TFYOLOV3",
"match_kind": "general",
"custom_attributes": {
"classes": 3,
"anchors": [12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401],
"coords": 4,
"num": 9,
"masks":[[0, 1, 2], [3, 4, 5], [6, 7, 8]],
"entry_points": ["detector/yolo-v4/Reshape", "detector/yolo-v4/Reshape_4", "detector/yolo-v4/Reshape_8"]
}
}
]

[ ERROR ] Part of the nodes was not converted to IR. Stopped.

environment:
unbuntu 16.04
openvino 2020.2
tensorflow 1.12.0

use OpenVINO Model Optimizer to convert .pb(Tensorflow) ->IR(OpenVINO .xml .bin .mapping )
python "/DATA/intel/openvino_2020.2.120/deployment_tools/model_optimizer/mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1
[ ERROR ] List of operations that cannot be converted to Inference Engine IR:
[ ERROR ] Softplus (72)
[ ERROR ] detector/cspdarknet-53/Conv/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_1/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_3/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_4/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_5/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_6/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_2/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_7/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_8/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_10/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_11/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_12/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_13/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_14/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_15/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_9/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_16/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_17/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_19/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_20/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_21/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_22/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_23/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_24/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_25/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_26/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_27/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_28/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_29/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_30/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_31/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_32/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_33/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_34/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_35/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_36/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_18/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_37/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_38/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_40/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_41/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_42/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_43/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_44/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_45/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_46/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_47/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_48/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_49/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_50/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_51/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_52/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_53/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_54/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_55/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_56/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_57/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_39/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_58/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_59/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_61/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_62/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_63/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_64/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_65/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_66/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_67/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_68/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_69/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_70/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_60/Softplus
[ ERROR ] detector/cspdarknet-53/Conv_71/Softplus
[ ERROR ] Part of the nodes was not converted to IR. Stopped.

Is the vision of OPENVINO cause the questions? And could you tell me the speed of yolov4 in OPENVINO? Thanks a lot!

Sync version for yolov4?

Hi!

Your code works great, thanks for this repository. Is there a synchronous version for Yolov4? I tried to run the yolov4 converted network on a typical openvino sync script "object_detection_sample_ssd.py" script works, but bounding boxes draws in the wrong positions.

run object_detection_demo_yolov4_async.py

when i run inference code,i get this error,what is it?how can i solve it? thank you~

[ INFO ] Creating Inference Engine...
[ INFO ] Loading network
Traceback (most recent call last):
File "object_detection_demo_yolov4_async.py", line 521, in
sys.exit(main() or 0)
File "object_detection_demo_yolov4_async.py", line 323, in main
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
File "ie_api.pyx", line 261, in openvino.inference_engine.ie_api.IECore.read_network
File "ie_api.pyx", line 285, in openvino.inference_engine.ie_api.IECore.read_network
ValueError: invalid stoi argument

The converted OpenVINO IR (xml, bin) model files not work in dlstreamer

I converted darknet YOLOv4 to tensorflow pb file and then to OpenVINO IR Files using the method in the repos.
The converted model (yolov4-coco.xml,yolov4-coco.bin) can work in OpenVINO inference engine. I can run the demo in the OpenVINO repos. But it doesnt work in dlstreamer pipeline. The whole process can be found here

ValueError: cannot reshape array of size 4571650 into shape (1024,512,3,3)

python convert_weights_pb.py --class_names models/self_make.names --weights_file models/self_make-yolov4_last.weights --data_format NHWC --size 608

My model cannot be converted and has been subject to this error:

File "/xxx/OpenVINO-YOLOV4/utils.py", line 115, in load_weights (shape[3], shape[2], shape[0], shape[1]))
ValueError: cannot reshape array of size 4571650 into shape (1024,512,3,3)

Error with yolov4-tiny inference

Hi! I have tried converting yolov4.weights (full model) and running an inference, everything works fine.
However, when I do the same thing but with yolov4-tiny.weights (tiny version) everything is okay until object_detection_demo_yolov3_async.py starts the inference. Then this error occurs:

[ INFO ] Creating Inference Engine...
[ INFO ] Loading network
[ INFO ] Preparing inputs
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (898) open OpenCV | GStreamer warning: unable to query duration of stream
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=0, duration=-1
[ INFO ] Loading model to the plugin
[ INFO ] Starting inference...

Traceback (most recent call last):
  File "object_detection_demo_yolov3_async.py", line 518, in <module>
    sys.exit(main() or 0)
  File "object_detection_demo_yolov3_async.py", line 398, in main
    args.keep_aspect_ratio)
  File "object_detection_demo_yolov3_async.py", line 233, in get_objects
    out_blob = out_blob.buffer.reshape(net.layers[net.layers[layer_name].parents[0]].out_data[0].shape)
KeyError: 'detector/yolo-v4-tiny/strided_slice/Split.0'

Does somebody know why it works for the full version but not for the tiny version?
Any help is very much appreciated.

ERROR when runing demo

environment:
ubuntu18.04 64bit
openvino 2020.4

Traceback (most recent call last):
File "object_detection_demo_yolov3_async.py", line 33, in
import monitors
ModuleNotFoundError: No module named 'monitors'

Difference Inference result after the conversion.

Hello thank you for your work

I have a question for you. I have correctly converted a custom .weigth to openvino format. After converting to the openvino format, I was able to see a decrease in general performance as regards the quality of the detection. On average I noticed an 8% decrease in the neural network's ability to detect my custom objects. It's normal? Do you have any advice to be able to bring the quality of the results closer to those of the original weigth.
I noticed that the loss of quality occurs in the transformation .weight to .pb

Thank you

how to use multiple NCS2?

i want to use 2 NCS2 in 2021.3/....py, but can only use one with -d MYRIAD
i wonder where should be modified in code?

Couldnt convert to OpenVino

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

No module named 'ngraph'

Hi, I run the code on raspberry 4B, but reported error.
Traceback (most recent call last):
File "yolov4-tiny-detection.py", line 15, in
import ngraph as ng
ModuleNotFoundError: No module named 'ngraph'

problem about YOLOv4 implement on openivno2021.X

Honor to know about your work about YOLOv4 implement on openivno2021.X . What I am doing is similar to yours but doesnot as well as your.
I am not familiar with the detailed Python implement about the model and just use the openvino to do the model transfermation and inference.
I scaned your file named OpenVINO-YOLO-Automatic-Generation/yolov4parse/cfg/yolov4.cfg. So I wonder how to check which part of YOLOv4 is suppported by openvino2021.2? Or what I need to learn?
In the .cfg file,I find you use SPP,CIOU, MISH,MOSAIC and GREEDYNMS metioned in YOLOv4 paper.

Can it be used in NSC2?

I train yolov4 model and convert it to openvino. It can work well in CPU but cannot be loaded in NSC2. Does anyone have a try like this?

How to run it with GPU

You showed this:

#windows  default OpenVINO path

python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4.weights --data_format NHWC

"C:\Program Files (x86)\IntelSWTools\openvino\bin\setupvars.bat"

python "C:\Program Files (x86)\IntelSWTools\openvino_2020.4.287\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolov4.json --batch 1 --reverse_input_channels

python object_detection_demo_yolov3_async.py -i cam -m frozen_darknet_yolov4_model.xml  -d CPU

But, how should I modify these code for running (testing) on GPU?

yolov4

can transform yolov4 weight to pb?

Convert Scaled YoloV4

Hi TNTWEN,

As an enhancement request. Will you be supporting Scaled Yolo V4? This will be nice thanks.

ValueError: cannot reshape array of size 251802 into shape (512,512,3,3)

python3 convert_weights_pb.py --class_names coco_pf.names --weights_file yolov4-tiny-_final.weights --data_format NHWC --tiny
Hello, when I use the above command, I give the following error report
ValueError: cannot reshape array of size 251802 into shape (512,512,3,3)
How to solve this problem, thank you very much

openvino CPP

Excuse me, may I use openvino routines to drive yolov4-tiny? I hope this can be faster,and use it by AI-boXX1

run object_detection_demo_yolov3_async.py throw exception(ZeroDivisionError: division by zero)

python object_detection_demo_yolov3_async.py -i D://bike.avi -m frozen_darknet_yolov4_model.xml -d CPU

(tf1.x) C:\Users\10048720\Downloads\OpenVINO-YOLOV4-master>python object_detecti
on_demo_yolov3_async.py -i D://bike.avi -m frozen_darknet_yolov4_model.xml -d C
PU
[ INFO ] Creating Inference Engine...
[ INFO ] Loading network
[ INFO ] Preparing inputs
MFX: Can't initialize session
[ WARN:0] global C:\jenkins\workspace\OpenCV\OpenVINO\2020.4\build\windows\openc
v\modules\videoio\src\cap_msmf.cpp (682) CvCapture_MSMF::initStream Failed to se
t mediaType (stream 0, (320x240 @ 15) MFVideoFormat_RGB24(unsupported media type
)
[ INFO ] Loading model to the plugin
[ INFO ] Starting inference...
To close the application, press 'CTRL+C' here or switch to the output window and
press ESC key
To switch between min_latency/user_specified modes, press TAB key in the output
window
[ INFO ]
[ INFO ] Mode: USER_SPECIFIED
[ INFO ] FPS: 0.0
Traceback (most recent call last):
File "object_detection_demo_yolov3_async.py", line 518, in
CreateFile() Error: 2
sys.exit(main() or 0)
File "object_detection_demo_yolov3_async.py", line 510, in main
CreateFile() Error: 2
mode_info[mode_value].frames_count) * 1e3))
ZeroDivisionError: division by zero

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.