object-detection-opencv icon indicating copy to clipboard operation
object-detection-opencv copied to clipboard

'module' has no 'readNet'

Open bebe04 opened this issue 7 years ago • 33 comments

hi,

i'm trying to use yolo but when i use the command $ python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt

i get the following error

Traceback (most recent call last):
  File "yolo_opencv.py", line 57, in <module>
    net = cv2.dnn.readNet(args.weights, args.config)
AttributeError: 'module' object has no attribute 'readNet'

i'm using python 2.7.12

if I use python 3 $ python3 yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt i get this error

Traceback (most recent call last):
  File "yolo_opencv.py", line 8, in <module>
    import cv2
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

how can i solve this error? (both would be nice, i would like to use python3 if it's possible)

bebe04 avatar Oct 24 '18 13:10 bebe04

you probably have a problem with python3. Try to uninstall it

shaarkrat2 avatar Oct 25 '18 06:10 shaarkrat2

Hello @bebe04 , install the dependencies using pip3 and run the script using python3. pip3 install numpy opencv-python python3 yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt

arunponnusamy avatar Oct 26 '18 10:10 arunponnusamy

@bebe04 I had the same problem with python 2.7 and opencv 3.3.0.

net = cv2.dnn.readNet(args.weights, args.config) AttributeError: 'module' object has no attribute 'readNet'

I installed the OpenCV 4.0.0 and this fixed the problem with readNet. According to OpenCV -> readNet compatibility > OpenCV3.3: https://docs.opencv.org/4.0.0/d6/d0f/group__dnn.html#ga3b34fe7a29494a6a4295c169a7d32422

peuris avatar Dec 01 '18 08:12 peuris

@arunponnusamy exactly the same problem here as @bebe04. I tried all the suggestions, nothing seems to work so far.

nand22 avatar Mar 28 '19 15:03 nand22

@nand22 May I know the Python and OpenCV version you are working with and the command you are trying to execute ?

arunponnusamy avatar Mar 29 '19 08:03 arunponnusamy

error:

err

sundharsk avatar Apr 05 '19 09:04 sundharsk

modify cv2.dnn.readNet to cv2.dnn.readNetFromDarknet

trantuanvu1602 avatar Apr 12 '19 04:04 trantuanvu1602

@sundharsk May I know the Python and OpenCV version you are working with ?

arunponnusamy avatar Apr 12 '19 13:04 arunponnusamy

@arunponnusamy i am having python version 3.5.5 and openCV version 3.4.1. I am also having the same problem. please suggest the way to solve this.

anamika06jain avatar May 05 '19 12:05 anamika06jain

Try with the latest version of OpenCV. That should solve the issue I hope.

arunponnusamy avatar May 05 '19 12:05 arunponnusamy

@arunponnusamy Now New error is coming " error: (-2:Unspecified error) Cannot determine an origin framework of files: in function 'cv::dnn::dnn4_v20190122::readNet'"

anamika06jain avatar May 05 '19 14:05 anamika06jain

how do I update OpenCV?

Rishan123 avatar May 12 '19 10:05 Rishan123

May I know the Python and OpenCV version you are working with ?

Using Raspberry Pi 3 and Python3

Rishan123 avatar May 12 '19 10:05 Rishan123

modify cv2.dnn.readNet to cv2.dnn.readNetFromDarknet

I tried that and it still got an error, this time:

Traceback (most recent call last): File "yolo.py", line 34, in <module> net = cv2.dnn.readNetFromDarknet(args.weights, args.config) AttributeError: module 'cv2.dnn' has no attribute 'readNetFromDarknet'

Rishan123 avatar May 12 '19 11:05 Rishan123

I also has the problem. Updation of opencev version helps me.

On Sun 12 May, 2019, 4:38 PM Rishan123, [email protected] wrote:

modify cv2.dnn.readNet to cv2.dnn.readNetFromDarknet

I tried that and it still got an error, this time:

Traceback (most recent call last): File "yolo.py", line 34, in net = cv2.dnn.readNetFromDarknet(args.weights, args.config) AttributeError: module 'cv2.dnn' has no attribute 'readNetFromDarknet'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arunponnusamy/object-detection-opencv/issues/8#issuecomment-491585900, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3UKLNDDF2I6XMFKIEJPNDPU73BBANCNFSM4F67YRWQ .

anamika06jain avatar May 12 '19 11:05 anamika06jain

Can you please tell me how to update opencv?

Rishan123 avatar May 12 '19 12:05 Rishan123

What version of opencev u r using?

On Sun 12 May, 2019, 6:08 PM Rishan123, [email protected] wrote:

Can you please tell me how to update opencv?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arunponnusamy/object-detection-opencv/issues/8#issuecomment-491592119, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3UKLI3GOA7X5B56RGWOFLPVAFWDANCNFSM4F67YRWQ .

anamika06jain avatar May 12 '19 13:05 anamika06jain

3

Rishan123 avatar May 12 '19 14:05 Rishan123

Update that with opencv 4. U can use uodate command or just write pip install opencv4.0

On Sun 12 May, 2019, 7:56 PM Rishan123, [email protected] wrote:

3

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arunponnusamy/object-detection-opencv/issues/8#issuecomment-491600467, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3UKLMZGK7OFSYD4RC5QUTPVASLBANCNFSM4F67YRWQ .

anamika06jain avatar May 12 '19 15:05 anamika06jain

I tried that, but I got:

ERROR: Could not find a version that satisfies the requirement opencv4.0 (from versions: none) ERROR: No matching distribution found for opencv4.0

Rishan123 avatar May 13 '19 06:05 Rishan123

Using Raspberry Pi

Rishan123 avatar May 13 '19 06:05 Rishan123

I have not tried that on raspbery pi.. i was doing that on windows system.

On Mon 13 May, 2019, 12:15 PM Rishan123, [email protected] wrote:

Using Raspberry Pi

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arunponnusamy/object-detection-opencv/issues/8#issuecomment-491696260, or mute the thread https://github.com/notifications/unsubscribe-auth/AI3UKLO32RLXUYQHVCMSY33PVEFCDANCNFSM4F67YRWQ .

anamika06jain avatar May 13 '19 06:05 anamika06jain

It should probably be the same.

Rishan123 avatar May 13 '19 15:05 Rishan123

I found another website, that usses pi 3b:

http://funofdiy.blogspot.com/2018/08/deep-learning-with-raspberry-pi-real.html

Rishan123 avatar May 13 '19 16:05 Rishan123

Can you please tell me how to update opencv?

For me I have to uninstall my older version of OpenCv and them reinstall version 4. Solved my problem with dnn.readNet() not found (Windows).

Murilo-ZC avatar Jul 17 '19 15:07 Murilo-ZC

Use pip install opencv-python==4.0.0.21 should resolve your issue

hunaidkhan2000 avatar Aug 14 '19 11:08 hunaidkhan2000

Upgrading opencv from 3.4.1 to 4.1.1 resolved this issue.

Download and install Latest OpenCV WHL file

sarathsrk avatar Sep 14 '19 04:09 sarathsrk

C:\Users\User\anomaly>python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt

i get the following error:

Traceback (most recent call last): File "yolo_opencv.py", line 57, in net = cv2.dnn.readNet(args.weights, args.config) cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\dnn\src\darknet\darknet_importer.cpp:214: error: (-212:Parsing error) Failed to parse NetParameter file: yolov3.weights in function 'cv::dnn::dnn4_v20190902::readNetFromDarknet'

Marshajennifer avatar Jan 23 '20 06:01 Marshajennifer

Since I couldn't update opencv using Python 3.6, my solution was to create a new environment with Python 3.7 and it allowed me to install a recent opencv version.

gfesquivelt avatar Mar 14 '20 11:03 gfesquivelt

Hi, I'm using YOLO Pre-trained model for live video streams, i got this error:: error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\darknet\darknet_io.cpp:677: error: (-212:Parsing error) Unknown layer type: in function 'cv::dnn::darknet::ReadDarknetFromCfgStream'

HebaGamalElDin avatar Apr 14 '20 14:04 HebaGamalElDin