Ask Your Question
0

AttributeError: 'dnn' object has no attribute 'writeTextGraph'

asked 2018-09-17 08:39:42 -0600

ayad gravatar image

updated 2018-09-17 09:52:15 -0600

berak gravatar image

Hello, Im trying to load a pretrained Tensorflow model using OpenCV by following the steps in the below link: https://github.com/opencv/opencv/wiki... When i try to generate a text representation of the graph by using the script tf_text_graph_ssd.py ,Im getting the error AttributeError: 'dnn' object has no attribute 'writeTextGraph' . I have the OpenCv 3.4 installed on my machine and I checked that dnn doesnt have an attribute or method under that name by running dir(dnn) in python after importing the library . When I chekced the online documentation ,I could find it exists : https://docs.opencv.org/trunk/d6/d0f/... but not in opencv python . I dont know what I am missing here .How can I fix the error ?

Thanks Ayad

edit retag flag offensive close merge delete

Comments

cv2.__version__ ? how did you install it ?

berak gravatar imageberak ( 2018-09-17 09:14:36 -0600 )edit

hmm, last attempt at python bindings here 2018:07:05 -- does not have it, either.

berak gravatar imageberak ( 2018-09-17 09:51:22 -0600 )edit

would you be able to rebuild it from the current 3.4 branch ? it seems, that it was added 14 days ago.

berak gravatar imageberak ( 2018-09-17 10:00:01 -0600 )edit

Or use tf_text_graph_ssd.py from the same version of OpenCV. Keep things synced.

dkurt gravatar imagedkurt ( 2018-09-17 10:56:43 -0600 )edit

@dkurt, it says in the wiki, that 3.4.1 can be used. clearly not so for cv.dnn.writeTextGraph()

berak gravatar imageberak ( 2018-09-17 11:04:45 -0600 )edit

@dkurt ,thanks.I installed opencv using pip .Im new to opencv so not really sure how to build it from source .So what do you suggest ?

ayad gravatar imageayad ( 2018-09-17 12:27:29 -0600 )edit

I have the same issue. I tried "pip install" and also compiled the opencv 3.4.3 source codes by myself. Both have the same error "module 'cv2.dnn' has no attribute 'writeTextGraph".

GnetUohz gravatar imageGnetUohz ( 2018-09-17 16:02:01 -0600 )edit
1

@berak, you're right. We've prepared a PR with tensorflow fallback in case of outdated OpenCV: https://github.com/opencv/opencv/pull....

dkurt gravatar imagedkurt ( 2018-09-18 01:15:34 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-09-18 11:08:05 -0600

You might check this link: https://github.com/opencv/opencv/issu...

It is possible that you are not using the latest source codes. I downloaded the latest 3.4 source codes in github directly using; wget https://github.com/opencv/opencv/arch... -O opencv-3.4.zip wget https://github.com/opencv/opencv_cont... -O opencv_contrib-3.4.zip And they do work.

You might need to compile the source codes by yourself (https://www.pyimagesearch.com/2016/10...). Just to make sure all related DNN options are ON, when you compile the source codes.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-09-17 08:39:42 -0600

Seen: 1,445 times

Last updated: Sep 18 '18