Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

How to use a keras custom trained classifier's .pb file inside OpenCV DNN module

$
0
0
I'm having trouble using the .pb file generated with keras, I think this is because I don't have a .pbtxt file but I can't generate one for that I would need a .config file and a relevant script (all scripts currently are for ssd and faster rcnn) from tensorflow.keras.applications.vgg16 import VGG16 import cv2 model = VGG16(weights='imagenet') model.save("vgg") net = cv2.dnn.readNetFromTensorflow("vgg/saved_model.pb") Error: **OpenCV(4.1.2) /io/opencv/modules/dnn/src/tensorflow/tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: vgg/saved_model.pb in function 'ReadTFNetParamsFromBinaryFileOrDi** **Tensorflow:** 2.2.0 **Opencv:** 4.3.0 **Note:** *Ofcourse I will use fine tuning to train this vgg before saving it, this is just the bare bones code to re produce the error.* Also I'm successfully able to use the classifier if I save it in .h5 and then convert to .onnx and then use it in opencv but I'm wondering how to use it in .pb Thanks

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>