AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.69k stars 7.96k forks source link

Model Performance Reduced on NCS2 #2879

Open Maria-UET opened 5 years ago

Maria-UET commented 5 years ago

@AlexeyAB , Hi,

I fine tuned the Yolo v3 Tiny weights with 6000+ image dataset, and changed the number of filters as per my required number of classes (80 classes reduced to 20). Then I transformed the weights and config file to tensorflow model (.pb) and then to IR format required for NCS2.

The performance (in Frames per second) has been significantly reduced in comparison to original network i.e. 4 times.

Can fine-tuning cause performance reduction?

AlexeyAB commented 5 years ago

@Maria-UET Hi,

Can fine-tuning cause performance reduction?

Then I transformed the weights and config file to tensorflow model (.pb) and then to IR format required for NCS2.

alexanderfrey commented 5 years ago

@Maria-UET Can you share the details on how you did the conversion to the NCS2 bin format ?

Maria-UET commented 5 years ago

@alexanderfrey sorry for the delayed response.

I used this tool for conversion cfg+weights to .pb files: https://github.com/feng1sun/YOLO-OpenVINO/tree/master/v3ConvertTool

Then I followed the documentation of OpenVINO for conversion .pb to IR (NCS2 bin format): https://docs.openvinotoolkit.org/R5/_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html

This approach works fine for Yolo version 2 and 3 but it gives multiple errors for Yolo v3 tiny. So I used this tool for getting the model ready for NCS2: https://github.com/mystic123/tensorflow-yolo-v3/blob/master/convert_weights_pb.py

The exact commands were as follows: python convert_weights_pb.py -class_names D:\voc.names -weights_file yolov3-tiny_last.weights --tiny True --size=416 --data_format=NHWC

and then

python C:\Intel\computer_vision_sdk_2018.5.456\deployment_tools\model_optimizer\mo_tf.py --data_type FP16 --input_model frozen_tiny_yolov3_model.pb --tensorflow_use_custom_operations_config frozen_tiny_yolo_prime.json --output_dir Tiny2 --batch=1

Also my frozen_tiny_yolo_prime.json file was as follows:

[ { "id": "TFYOLOV3", "match_kind": "general", "custom_attributes": { "classes": 20, "coords": 4, "num": 6, "mask": [0,1,2], "jitter":0.3, "ignore_thresh":0.7, "truth_thresh":1, "anchors":[10,14,23,27,37,58,81,82,135,169,344,319], "random":1, "entry_points": ["detector/yolo-v3-tiny/Reshape","detector/yolo-v3-tiny/Reshape_4"] } } ]

Note that I am only using 20 classes for Yolo v3 tiny.

dexception commented 5 years ago

@Maria-UET Are you sure this tool was able to convert all the yolo layers to OpenVino ? Last time i checked only 1 yolo layers was giving output.

Also the NCS2 stick is not powerful enough. I was only getting 6 FPS on mobilenet.