experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 787 forks source link

Convert *.h5 (keras model) into *.pb and *.pbtxt (tensorflow model), and load them by opencv dnn #463

Open namnguyenphuong10 opened 3 years ago

namnguyenphuong10 commented 3 years ago

I converted completely keras model (full yolo v2) into tensorflow model, then i loaded them by tensorflow and carried out exactly however i can not load them by cv2.dnn.readNetFromTensorflow(). I got a problem while loading tensorflow model by using dnn.

Code bellow:

import cv2 net = cv2.dnn.readNetFromTensorflow('model.pb', './model.pbtxt')

error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/tensorflow/tf_importer.cpp:663: error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'addConstNodes'

Did anyone get the same issue and seek out solutions? Thanks a lot.