Unable to import tensorflow object detection model in opencv dnn ?

asked 2017-10-17 08:09:30 -0600

ManojGuha gravatar image

updated 2017-10-17 08:48:46 -0600

Hi everyone, I had trained tensorflow object detection model with my own dataset and I had obtained the .pb and .prototxt files after training. When I tried to load the model and prototxt file in this opencv dnn sample code, I am always getting an error saying that cv.dnn.readNetFromTensorflow() accepts only 1 argument but 2 arguments given. But in the sample code 2 arguments are given. I new to opencv and dnn and don't know how to load the .pb tensorflow file into the opencv dnn code. Should I make any modifications ? Please help me . Thanks :)

edit retag flag offensive close merge delete

Comments

1

@ManojGuha, first of all you need to update OpenCV to the latest state from the master branch. Then check that import cv2 imports it from the correct place (check print(cv2.__file__)). Also it'd be better to know the kind of model (sample is used for MobileNet-SSD architecture), configuration file you used to define a model (like a https://github.com/tensorflow/models/...).

dkurt gravatar imagedkurt ( 2017-10-17 12:13:45 -0600 )edit

I think that in 3.3.0 the function only takes one argument which is the path to the .pb file.

CV_EXPORTS_W Net readNetFromTensorflow(const String &model);
jingyibo123 gravatar imagejingyibo123 ( 2017-10-19 07:21:21 -0600 )edit
1

@jingyibo123, no, there were recent changes, see here

berak gravatar imageberak ( 2017-10-19 08:15:54 -0600 )edit