PINTO0309 / OpenVINO-YoloV3

YoloV3/tiny-YoloV3+RaspberryPi3/Ubuntu LaptopPC+NCS/NCS2+USB Camera+Python+OpenVINO
https://qiita.com/PINTO
Apache License 2.0
538 stars 165 forks source link

RuntimeError: Error reading network #37

Closed eddex closed 5 years ago

eddex commented 5 years ago

device: Raspberry Pi 3 B+

CPU architecture: Intel Compute Stick 2 (MYRIAD)

OS: Raspbian Stretch Lite (April 2019)

What I did: 1) Download original yolov3-tiny.weights from https://pjreddie.com/media/files/yolov3-tiny.weights 2) Convert yolov3-tiny.weights to tf model:

python3 tensorflow-yolo-v3/convert_weights_pb.py 
--class_names coco.names --data_format NHWC 
--weights_file yolov3-tiny.weights --tiny

3) Convert tf model to IR:

python3 mo_tf.py --input_model frozen_darknet_yolov3_model.pb 
--tensorflow_use_custom_operations_config yolo_v3_tiny.json 
--input_shape [1,416,416,3]

4) copy frozen_darknet_yolov3_model.xml and frozen_darknet_yolov3_model.bin to Raspberry Pi 5) run python3 openvino_tiny-yolov3_test.py -d MYRIAD on Raspberry Pi

Error message:

pi@raspberrypi:~ $ python3 openvino_tiny-yolov3_test.py -d MYRIAD
Traceback (most recent call last):
  File "openvino_tiny-yolov3_test.py", line 239, in <module>
    sys.exit(main_IE_infer() or 0)
  File "openvino_tiny-yolov3_test.py", line 168, in main_IE_infer
    net = IENetwork(model=model_xml, weights=model_bin)
  File "ie_api.pyx", line 271, in openvino.inference_engine.ie_api.IENetwork.__cinit__
RuntimeError: Error reading network: in Layer detector/yolo-v3-tiny/pool2/MaxPool: 
trying to connect an edge to non existing output port: 2.1

Overview of problems and questions: I'm not quite sure what this error means. Is there a difference between the yolov3-tiny.weights used in this repository and the original ones? And if so, how can I get the openvino_tiny-yolov3_test.py running with the original yolov3-tiny.weights?

When I use the files from OpenVINO-YoloV3/lrmodels/tiny-YoloV3/FP16/, the error doesn't show up.

I tried to adapt the openvino_tiny-yolov3_test.py by changing the num = 3 variable to num = 6 since the original yolov3-tiny.cfg uses this number. But this didn't make a difference.

eddex commented 5 years ago

I figured out what the issue was.

The conversion of the yolov3-tiny.weights has to be done with tensorflow <1.13.0 otherwise something goes wrong.

To fix the issue I installed tensorflow 1.12.2

pip3 install tensorflow==1.12.2

And then converted the yolov3-tiny.weights using the same command as before (see step 2 on the previous comment).

I also added the --data_type parameter when converting the tensorflow model to the intermediate representation:

python3 mo_tf.py --input_model frozen_darknet_yolov3_model.pb 
--tensorflow_use_custom_operations_config yolo_v3_tiny.json 
--input_shape [1,416,416,3]
--data_type FP16

Like this the error doesn't show up anymore.

I found this information here: https://software.intel.com/en-us/forums/computer-vision/topic/807383