Ask Your Question

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

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

ayad gravatar image

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

berak gravatar image

Hello, Im trying to load a pretrained Tensorflow model using OpenCV by following the steps in the below link: When i try to generate a text representation of the graph by using the script ,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 : 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


cv2.__version__ ? how did you install it ?

berak gravatar imageberak ( 2018-09-17 09:14:36 -0500 )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 -0500 )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 -0500 )edit

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

dkurt gravatar imagedkurt ( 2018-09-17 10:56:43 -0500 )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 -0500 )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 -0500 )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 -0500 )edit

@berak, you're right. We've prepared a PR with tensorflow fallback in case of outdated OpenCV:

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

1 answer

Sort by ยป oldest newest most voted

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

You might check this link:

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 -O wget -O And they do work.

You might need to compile the source codes by yourself ( Just to make sure all related DNN options are ON, when you compile the source codes.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 409 times

Last updated: Sep 18 '18