Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'module' has no 'readNet' #8

Open
bebe04 opened this issue Oct 24, 2018 · 33 comments
Open

'module' has no 'readNet' #8

bebe04 opened this issue Oct 24, 2018 · 33 comments

Comments

@bebe04
Copy link

bebe04 commented Oct 24, 2018

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)

@shaarkrat2
Copy link

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

@arunponnusamy
Copy link
Owner

arunponnusamy commented Oct 26, 2018

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

@peuris
Copy link

peuris commented Dec 1, 2018

@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

@nand22
Copy link

nand22 commented Mar 28, 2019

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

@arunponnusamy
Copy link
Owner

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

@sundharsk
Copy link

error:

err

@trantuanvu1602
Copy link

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

@arunponnusamy
Copy link
Owner

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

@anamika06jain
Copy link

@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.

@arunponnusamy
Copy link
Owner

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

@anamika06jain
Copy link

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

@Rishan123
Copy link

how do I update OpenCV?

@Rishan123
Copy link

Rishan123 commented May 12, 2019

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

Using Raspberry Pi 3 and Python3

@Rishan123
Copy link

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'

@anamika06jain
Copy link

anamika06jain commented May 12, 2019 via email

@Rishan123
Copy link

Can you please tell me how to update opencv?

@anamika06jain
Copy link

anamika06jain commented May 12, 2019 via email

@Rishan123
Copy link

3

@anamika06jain
Copy link

anamika06jain commented May 12, 2019 via email

@Rishan123
Copy link

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
Copy link

Using Raspberry Pi

@anamika06jain
Copy link

anamika06jain commented May 13, 2019 via email

@Rishan123
Copy link

It should probably be the same.

@Rishan123
Copy link

I found another website, that usses pi 3b:

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

@Murilo-ZC
Copy link

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).

@hunaidkhan2000
Copy link

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

@sarathsrk
Copy link

sarathsrk commented Sep 14, 2019

Upgrading opencv from 3.4.1 to 4.1.1 resolved this issue.

Download and install Latest OpenCV WHL file

@Marshajennifer
Copy link

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'

@gfesquivelt
Copy link

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.

@HebaGamalElDin
Copy link

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'

@Mimun
Copy link

Mimun commented May 20, 2020

readNetFromDarknet

error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/darknet/darknet_importer.cpp:207: error: (-212:Parsing error) Failed to parse NetParameter file: yolov3.weights in function 'readNe

@fatima598
Copy link

readNetFromDarknet

error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/darknet/darknet_importer.cpp:207: error: (-212:Parsing error) Failed to parse NetParameter file: yolov3.weights in function 'readNe

dawnload another file of yolov3.weights

@psk1998
Copy link

psk1998 commented Sep 21, 2020

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'

I got the same error, how did you fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests