I've converted my yolov3 model to .pb and them to .bin and .xml using the official instructions, but when I run it on the NCS2 it puts label boxes everywhere. If I test the origional yolov3 model it works perfectly, so I'm thinking something has gone wrong in the conversion. I'm using tensorflow 1.12, as I read newer versions can cause problems. One area I'm struggling with is configuring the .json file as there is next to no information about what needs to go in this.
I've attached the cfg and the json in a .7z file if someone can take a look and advise me what needs to go where.
Any help would be massively apreciated!
It's likely an issue with the json file or how the model was converted. I've trained a tiny YOLOv3 model using Darknet. Once I had the weight file, I converted to .pb using the following steps (also listed here):
git clone https://github.com/mystic123/tensorflow-yolo-v3.git cd tensorflow-yolo-v3 git checkout ed60b90 python3 convert_weights_pb.py --class_names label.names --data_format NHWC --weights_file yolov3-tiny.weights --tiny
I used the following command to convert the frozen TensorFlow model to IR using the following command:
python3 <OpenVINO>/deployment_tools/model_optimizer/mo_tf.py --input_model frozen_darknet_yolov3_model.pb --tensorflow_use_custom_operations_config yolov3_tiny_custom.json --batch 1 --data_type FP16 --reverse_input_channels
Attached is the json configuration file that I used, I modified it to match the last yolo section in the .cfg file. Hope this helps!
Thats the same as me then. I've attached the weights and names files I'm using, as well as the .pb .bin and .xml files so you can test each step I'm doing. I've also included a test image.
Many thankfor your help!
Using OpenVINO toolkit 2019 R2.0.1, I converted your weight file to Tensorflow (.pb) to IR Format with the commands below. Then I ran the IR model using the object_detection_demo_yolov3_async and saw the wheelchair detections (see attached). I also ran the IR model you provided and saw similar results. How are you testing the model? Could you share the results you are seeing?
git clone https://github.com/mystic123/tensorflow-yolo-v3.git cd tensorflow-yolo-v3/ git checkout ed60b90 python3 convert_weights_pb.py --class_names wheelchairs.names --data_format NHWC --weights_file wheelchairs_yolov3-tiny_final.weights --tiny python3 ~/intel/openvino/deployment_tools/model_optimizer/mo_tf.py --input_model frozen_darknet_yolov3_model.pb --tensorflow_use_custom_operations_config yolo_v3_tiny.json --batch 1 --data_type FP16 --reverse_input_channels ./object_detection_demo_yolov3_async -m frozen_darknet_yolov3_model.xml -d MYRIAD -i cam
BTW, the sample uses a camera as input so I pointed the camera at the picture you provided. :)
Dear Batchelor, Peter,
That's odd ! I need to file a bug if that is the case. Anyway, you can find it here:
Are you 100% sure that it's missing from the 2019R2 RPI package ?
Let me know and I will certainly file a bug on your behalf.
Dear Batchelor, Peter,
OK it looks like leaving out some Python scripts was a design decision made "on purpose" to keep the RPI tar.gz package small. But the good news is that you can download it from the link I gave you above.
Have fun !
Let us know if you have more questions,
Thanks for that, we were wondering! Could the online guides be updated to explain this please? I'm trying a reinstall on my Pi today, so I'll see if that fixes it!
Thank you for providing your feedback, I will share with the appropriate team to improve our documentation. Let me know if you have additional questions.
I took a closer look at the sample code, it looks like the sample is for the full version of YoloV3 as it's not doing any calculations for the anchor offsets needed for tiny Yolo V3.
However, we have another sample demo for tiny YoloV3. Take a look at the following link: https://github.com/movidius/ncappzoo/tree/master/networks/TinyYolo_v3
You will need to make a couple of simple changes to match to your model.
Change Line 159 to match your model, I believe you only have 1 class:
num_of_classes = 1 #default 80
Use the following formula to calculate the number of values.If your model only has 1 class, you will have 6 values.
80 class scores + 4 coordinate values + 1 objectness score = 85 values
Update the values from "85 to "6" on lines 180, 184, 185, 186,187 and 191
box_confidence_score = output_node_results[row][col][anchor_boxes * 85 + 4]
Let me know if this works for you!
Glad it worked for you! We just released the Neural Compute Application Zoo (ncappzoo) for the Intel Neural Compute Stick 2 using the OpenVINO toolkit and will add it to the get started guide. Your project is very interesting, have you considered sharing your project on the ncappzoo repository?
Edit: The Get Started Guide for the Intel NCS 2 already contains a link to the ncappzoo repository.