Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Tensorflow Custom Model in OpenCV

I have trained new model on top of ssd_mobilenet_v1_coco for a custom data set. This model works fine in tensorflow. But now I want to use this in OpenCV.

net = cv2.dnn.readNetFromTensorflow("model/frozen_inference_graph.pb", "model/protobuf.pbtxt")
detections = net.forward()

So for the config file I convert frozen_graph to pbtxt and add it. But then I got the following error [libprotobuf ERROR /home/chamath/Projects/opencv/opencv/3rdparty/protobuf/src/google/protobuf/text_format.cc:298] Error parsing text-format tensorflow.GraphDef: 731:5: Unknown enumeration value of "DT_RESOURCE" for field "type".

As suggested here I try to use this config file mentioned in the thread but when I use it object detection is not working properly. Incorrect number of squares detected and they are misplaced.

Is there any method to create a pbtxt config file that works with OpenCV? Or any suggestions how to make my model work in OpenCV?

Tensorflow Custom Model in OpenCV

I have trained new model on top of ssd_mobilenet_v1_coco for a custom data set. This model works fine in tensorflow. But now I want to use this in OpenCV.

net = cv2.dnn.readNetFromTensorflow("model/frozen_inference_graph.pb", "model/protobuf.pbtxt")
detections = net.forward()

So for the config file I convert frozen_graph to pbtxt and add it. But then I got the following error [libprotobuf ERROR /home/chamath/Projects/opencv/opencv/3rdparty/protobuf/src/google/protobuf/text_format.cc:298] Error parsing text-format tensorflow.GraphDef: 731:5: Unknown enumeration value of "DT_RESOURCE" for field "type".

As suggested here I try to use this config file mentioned in the thread but when I use it object detection is not working properly. Incorrect number of squares detected and they are misplaced.

Is there any method to create a pbtxt config file that works with OpenCV? Or any suggestions how to make my model work in OpenCV?

Result in OpenCV :

image description

Result in Tensorflow

image description

Tensorflow Custom Model in OpenCV

I have trained new model on top of ssd_mobilenet_v1_coco for a custom data set. This model works fine in tensorflow. But now I want to use this in OpenCV.

net = cv2.dnn.readNetFromTensorflow("model/frozen_inference_graph.pb", "model/protobuf.pbtxt")
detections = net.forward()

So for the config file I convert frozen_graph to pbtxt and add it. But then I got the following error [libprotobuf ERROR /home/chamath/Projects/opencv/opencv/3rdparty/protobuf/src/google/protobuf/text_format.cc:298] Error parsing text-format tensorflow.GraphDef: 731:5: Unknown enumeration value of "DT_RESOURCE" for field "type".

As suggested here I try to use this config file mentioned in the thread but when I use it object detection is not working properly. Incorrect number of squares detected and they are misplaced.

Is there any method to create a pbtxt config file that works with OpenCV? Or any suggestions how to make my model work in OpenCV?

Result in OpenCV :

image description

Result in Tensorflow

image description