TNTWEN / OpenVINO-YOLOV4

This is implementation of YOLOv4,YOLOv4-relu,YOLOv4-tiny,YOLOv4-tiny-3l,Scaled-YOLOv4 and INT8 Quantization in OpenVINO2021.3
MIT License
240 stars 66 forks source link

Got error white coverting to IR using mo.py #44

Open tarunmcom opened 3 years ago

tarunmcom commented 3 years ago

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

TNTWEN commented 3 years ago

Hi @tarunmcom That's because you still use yolov4.json.Please use yolo_v4_tiny.json instead

su26225 commented 3 years ago

Hi @tarunmcom That's because you still use yolov4.json.Please use yolo_v4_tiny.json instead

I have encounter a similiar error.when i use the yolo_v4_tiny.json,I got [ ERROR ] Exception occurred during running replacer "TFYOLOV3" (<class 'extensions.front.YOLO.YoloV3RegionAddon'>): TensorFlow YOLO V3 conversion mechanism was enabled. Entry points "detector/yolo-v4-tiny/Reshape, detector/yolo-v4-ti ny/Reshape_4" were provided in the configuration file. Entry points are nodes that feed YOLO Region layers. Node with name detector/yolo-v4-tiny/Reshape doesn't exist in the graph. Refer to documentation about converting YOLO models fo r more information. thanks for your help!

TNTWEN commented 3 years ago

@su26225 So which model are you using? YOLOv4 or YOLOv4-tiny

su26225 commented 3 years ago

@su26225 So which model are you using?

I use yolov4-tiny.weights,after the train of darknet

TNTWEN commented 3 years ago

@su26225 check the .pb model you are using The error means the .pb model isn't converted by your yolov4-tiny.weights OR you can list all commands here

TNTWEN commented 3 years ago

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

you didn't add --tiny

su26225 commented 3 years ago

@su26225 check the .pb model you are using The error means the .pb model isn't converted by your yolov4-tiny.weights OR you can list all commands here

This is the cammands I used: ./darknet detector train /data2/darknet-master/build/darknet/x64/data/obj.data cfg/yolov4-tiny-custom.cfg /data2/darknet-master/yolov4-tiny.weights -map python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4-tiny-custom_last.weights --data_format NHWC python "C:\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

If I use the yolov4.json,I will get the error: [ ERROR ] Cannot infer shapes or values for node "detector/yolo-v4/Conv_23/biases". [ ERROR ] Attempting to use uninitialized value detector/yolo-v4/Conv_23/biases [[{{node _retval_detector/yolo-v4/Conv_23/biases_0_0}}]] [ ERROR ] [ ERROR ] It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x0000014FFAA861E0>. [ ERROR ] Or because the node inputs have incorrect values/shapes. [ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape). [ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information. [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4/Conv_23/biases" node. For more information please refer to Model Optimizer FAQ, question #38.

TNTWEN commented 3 years ago

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

TNTWEN commented 3 years ago

python "C:\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

This is also wrong

python "C:\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolo_v4_tiny.json --batch 1 --reverse_input_channels

su26225 commented 3 years ago

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

I got it . I used the convert_weights_pb.py in branch of v4-tiny-3l , it doesn't have the flag.tiny. Howevey , when i changed to use convert_weights_pb.py in master python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4-tiny-custom_last.weights --data_format NHWC --tiny python "C:\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolo_v4_tiny.json --batch 1 --reverse_input_channels I got the error : [ ERROR ] Cannot infer shapes or values for node "detector/yolo-v4-tiny/Conv_20/biases". [ ERROR ] Attempting to use uninitialized value detector/yolo-v4-tiny/Conv_20/biases [[{{node _retval_detector/yolo-v4-tiny/Conv_20/biases_0_0}}]] [ ERROR ] [ ERROR ] It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x0000018D46807510>. [ ERROR ] Or because the node inputs have incorrect values/shapes. [ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape). [ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information. [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4-tiny/Conv_20/biases" node. For more information please refer to Model Optimizer FAQ, question #38. sorry to bother you again!

TNTWEN commented 3 years ago

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

I got it . I used the convert_weights_pb.py in branch of v4-tiny-3l , it doesn't have the flag.tiny. Howevey , when i changed to use convert_weights_pb.py in master python convert_weights_pb.py --class_names cfg/coco.names --weights_file yolov4-tiny-custom_last.weights --data_format NHWC --tiny python "C:\Intel\openvino_2021.3.394\deployment_tools\model_optimizer\mo.py" --input_model frozen_darknet_yolov4_model.pb --transformations_config yolo_v4_tiny.json --batch 1 --reverse_input_channels I got the error : [ ERROR ] Cannot infer shapes or values for node "detector/yolo-v4-tiny/Conv_20/biases". [ ERROR ] Attempting to use uninitialized value detector/yolo-v4-tiny/Conv_20/biases [[{{node _retval_detector/yolo-v4-tiny/Conv_20/biases_0_0}}]] [ ERROR ] [ ERROR ] It can happen due to bug in custom shape infer function <function tf_native_tf_node_infer at 0x0000018D46807510>. [ ERROR ] Or because the node inputs have incorrect values/shapes. [ ERROR ] Or because input shapes are incorrect (embedded to the model or passed via --input_shape). [ ERROR ] Run Model Optimizer with --log_level=DEBUG for more information. [ ERROR ] Exception occurred during running replacer "REPLACEMENT_ID" (<class 'extensions.middle.PartialInfer.PartialInfer'>): Stopped shape/value propagation at "detector/yolo-v4-tiny/Conv_20/biases" node. For more information please refer to Model Optimizer FAQ, question #38. sorry to bother you again!

How many classes your custom model has? you should change number of classes in .json which has been mentioned in FAQ

su26225 commented 3 years ago

How many classes your custom model has? you should change number of classes in .json which has been mentioned in FAQ

yes,I have changed the number of classes from 80 to 2 , but it still have the error . I try to run the program in Linux , and then I get the .xml 、 .bin , although I don't know why

TNTWEN commented 3 years ago

How many classes your custom model has? you should change number of classes in .json which has been mentioned in FAQ

yes,I have changed the number of classes from 80 to 2 , but it still have the error . I try to run the program in Linux , and then I get the .xml 、 .bin , although I don't know why

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

you still use coco.names here

su26225 commented 3 years ago

you still use coco.names here

I have chaned the content of coco.names . It has only two labels in it . Now , I am still traped in the step of mo.py. Should I follow this branch of tiny.3l exactly for deployment , or switch to the master?

TNTWEN commented 3 years ago

It's clear that yolov4 and yolov4-tiny use master branch,yolov4-tiny-3l use tiny-3l branch And all commands are listed in corresponding README in detail. I recommend you download yolov4.weights yolov4-tiny.weights and try official model first. You should make sure you could run demo first

And then you only need to change coco.names and .json for custom model.

su26225 commented 3 years ago

It's clear that yolov4 and yolov4-tiny use master branch,yolov4-tiny-3l use tiny-3l branch And all commands are listed in corresponding README in detail. I recommend you download yolov4.weights yolov4-tiny.weights and try official model first. You should make sure you could run demo first

Thanks . I have solved this issue through upgrading tensorflow version from 1.15 to 2.0