david8862 / keras-YOLOv3-model-set

end-to-end YOLOv4/v3/v2 object detection pipeline, implemented on tf.keras with different technologies
MIT License
640 stars 222 forks source link

yolo5_small_darknet load in opencv #252

Open ksv87 opened 1 month ago

ksv87 commented 1 month ago

I trained yolo5_small_darknet Dump model with yolo.py Convert it to onnx with keras_to_onnx.py Convert it to frozen pb with keras_to_tensorflow.py Convert it to tflite with post_train_quant_convert.py

I try load frozen pb in opencv

tf = cv2.dnn.readNetFromTensorflow("test.pb")
error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:2877: error: (-2:Unspecified error) More than one input is Const op in function 'cv::dnn::dnn4_v20240521::`anonymous-namespace'::TFImporter::getConstBlob'

I try load tflite in opencv

tflite = cv2.dnn.readNetFromTFLite("test.tflite")
error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\tflite\tflite_importer.cpp:246: error: (-213:The function/feature is not implemented) Unsupported operator type STRIDED_SLICE in function 'cv::dnn::dnn4_v20240521::TFLiteImporter::populateNet'

I try load onnx in opencv

onnx = cv2.dnn.readNetFromONNX("test.onnx")
It's work

What I do wrong? How load frozen pb model in opencv? How load tflite model in opencv?