Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Unable to run yolov3_tiny with different input_size #42

Open
cfdcfc opened this issue Jun 4, 2019 · 4 comments
Open

Unable to run yolov3_tiny with different input_size #42

cfdcfc opened this issue Jun 4, 2019 · 4 comments

Comments

@cfdcfc
Copy link

cfdcfc commented Jun 4, 2019

Hi,

First of all, I have successfully implement openvino_tiny-yolov3_test.py.
Then, I would like to trade the accuracy for speed by reducing the input_size (416 -> 320), I have successfully achieve this in yolov3. However, I am not able to achieve this in yolov3_tiny, please see the below details:

get model
wget https://pjreddie.com/media/files/yolov3-tiny.weights

convert yolo to tensorflow
python3 /opt/OpenVINO-YoloV3/convert_weights_pb.py --class_names /opt/darknet/data/coco.names --weights_file /opt/darknet/yolov3-tiny.weights --data_format NHWC --output_graph /data/train/frozen_darknet_yolov3_tiny_model.pb --size 320 --tiny

convert tensorflow to IR
python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo_tf.py --input_model /data/train/frozen_darknet_yolov3_tiny_model.pb --tensorflow_use_custom_operations_config /opt/intel/openvino/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3_tiny.json --data_type FP16 --batch 1 --output_dir /data/train/

try to test with python(On Raspberry Pi Stretch with NCS2)

import os

try:
    from armv7l.openvino.inference_engine import IENetwork, IEPlugin
except:
    from openvino.inference_engine import IENetwork, IEPlugin
    
model_xml = "/home/pi/models/frozen_darknet_yolov3_tiny_model.xml"
model_bin = os.path.splitext(model_xml)[0] + ".bin"

plugin = IEPlugin(device="MYRIAD")
net = IENetwork(model=model_xml, weights=model_bin)
input_blob = next(iter(net.inputs))
exec_net = plugin.load(network=net)

Then error occurs:

Traceback (most recent call last):
File "yolov3_tiny_test.py", line 14, in
exec_net = plugin.load(network=net)
File "ie_api.pyx", line 395, in openvino.inference_engine.ie_api.IEPlugin.load
File "ie_api.pyx", line 406, in openvino.inference_engine.ie_api.IEPlugin.load
RuntimeError: [VPU] Internal error: Output in detector/yolo-v3-tiny/pool2_5/MaxPool has incorrect width dimension. Expected: 9 or 9 Actual: 10

@PINTO0309
Copy link
Owner

PINTO0309 commented Jun 12, 2019

  1. Install Tensorflow v1.12.0
$ sudo -H pip3 install tensorflow==1.12.0 --upgrade
  1. Execute below.
$ python3 /opt/intel/openvino/deployment_tools/model_optimizer/mo_tf.py \
--input_model /data/train/frozen_darknet_yolov3_tiny_model.pb \
--tensorflow_use_custom_operations_config /opt/intel/openvino/deployment_tools/model_optimizer/extensions/front/tf/yolo_v3_tiny.json \
--data_type FP16 \
--batch 1 \
--output_dir /data/train/ \
--input_shape [1,320,320,3]

@cfdcfc
Copy link
Author

cfdcfc commented Jun 13, 2019

Hi PINTO0309,

Thanks for the response, I followed your instruction but got this error:

[ ERROR ] Both --input_shape and --batch were provided. Please provide only one of them.
For more information please refer to Model Optimizer FAQ (<INSTALL_DIR>/deployment_tools/documentation/docs/MO_FAQ.html), question #56.

I removed the --batch 1 and successfully convert the tensorflow to IR, but eventually I end up with the same error like before

Traceback (most recent call last):
File "yolov3_tiny_test.py", line 14, in
exec_net = plugin.load(network=net)
File "ie_api.pyx", line 395, in openvino.inference_engine.ie_api.IEPlugin.load
File "ie_api.pyx", line 406, in openvino.inference_engine.ie_api.IEPlugin.load
RuntimeError: [VPU] Internal error: Output in detector/yolo-v3-tiny/pool2_5/MaxPool has incorrect width dimension. Expected: 9 or 9 Actual: 10

@PINTO0309
Copy link
Owner

Did you do it at 320 when training? I think it needs to be adjusted when training on Darknet.

@cfdcfc
Copy link
Author

cfdcfc commented Jun 17, 2019

I did not train at 320.
However, I was able to apply the same trick on normal yolo v3.

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

No branches or pull requests

2 participants