Ask Your Question
0

dnn, python3.6, cv3.4.1 object_detection error

asked 2018-04-06 01:55:32 -0600

Peshmerge gravatar image

updated 2018-04-06 02:11:03 -0600

berak gravatar image
System information (version)
  • OpenCV => 3.4.1
  • Operating System / Platform => Windows 64 Bit
  • Python=>3.6
Detailed description

I have Opencv 3.4.1 installed using pipby downloading a wheel file from https://www.lfd.uci.edu/~gohlke/pytho...

pip install opencv_python-3.4.1-cp36-cp36m-win_amd64.whl

pip install opencv_python-3.4.1+contrib-cp36-cp36m-win_amd64.whl

When I print the the version of the cv2 inside the script I got 3.4.1, but I can't rund the code of object_detection because of the following errors:

print(cv.__version__)

1.

Traceback (most recent call last):
File "object_detection.py", line 52, in <module>
net = cv.dnn.readNet(args.model, args.config, args.framework)
AttributeError: module 'cv2.dnn' has no attribute 'readNet'

I can solve this by replacing readNet with readNetFromCaffe while I use Caffe model . The moest weird thing is, when I go to the source of cv2/dnn.py I can't see the readNet() function!

2.

Traceback (most recent call last):
File "object_detection.py", line 155, in <module>
if net.getLayer(0).outputNameToIndex('im_info') != -1:  # Faster-RCNN or R-FCN
AttributeError: 'cv2.dnn_Layer' object has no attribute 'outputNameToIndex'

But I couldn't fix this one!

Anyone an idea why I can't find readNet()? while I have the latest version of opencv.

I have also built Opencv3.4.1 from source on Ubuntu and I still can't find the readNet() function!

edit retag flag offensive close merge delete

Comments

you need the latest master branch for this, not the 3.4.1 release (this also means, you have to build from src, and can't rely on easy PIP install)

(yes, you can use readNetFromCaffe readNetFromTorch, etc, but other things, like certain layers might be still missing)

there is no cv2/dnn.py what do you mean ?

berak gravatar imageberak ( 2018-04-06 02:08:45 -0600 )edit

Thanks for your answer! You would expect when the wheel file contains 3.4.1 as a version number, that it has the latest version!

I built yesterday opencv 3.4.1 from source on Ubuntu 16.04, I still can't find readNet().

I am using pycharm as editor. This is what I mean, check screenshot https://imgur.com/a/8ovVC

Peshmerge gravatar imagePeshmerge ( 2018-04-06 02:27:40 -0600 )edit

the PIP version numbers are frozen at the resp. opencv release (which is from febuary)

"I built yesterday opencv 3.4.1 from source" -- this might be the same problem.

berak gravatar imageberak ( 2018-04-06 02:29:19 -0600 )edit

It's unbelievable! I have just built it again from the source on Windows 10 using CMake, I still can't access readNet() !

Peshmerge gravatar imagePeshmerge ( 2018-04-06 05:56:16 -0600 )edit

maybe you should switch to git for downloading the src. (you'll also have to do that a few times in the future (bugfixes, updates), and you'd profit from incremental downloads)

berak gravatar imageberak ( 2018-04-06 06:03:04 -0600 )edit

What do you mean exactly? I have downloaded it from GitHub using this link https://github.com/opencv/opencv/arch...

Peshmerge gravatar imagePeshmerge ( 2018-04-06 06:05:02 -0600 )edit

@Peshmerge, Perhaps you're looking for 3.4.1-dev that means a state of library after 3.4.1 but before the future release: https://github.com/opencv/opencv/arch.... If you want to use scripts compatible with 3.4.1 you can find them in downloaded source code.

dkurt gravatar imagedkurt ( 2018-04-07 05:59:04 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-04-09 01:31:52 -0600

Peshmerge gravatar image

Thanks, I have solved it by coning the master branch and building it from source!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-04-06 01:55:32 -0600

Seen: 6,604 times

Last updated: Apr 09 '18