object-detection-opencv
object-detection-opencv copied to clipboard
'module' has no 'readNet'
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)
you probably have a problem with python3. Try to uninstall it
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
@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
@arunponnusamy exactly the same problem here as @bebe04. I tried all the suggestions, nothing seems to work so far.
@nand22 May I know the Python and OpenCV version you are working with and the command you are trying to execute ?
error:

modify cv2.dnn.readNet to cv2.dnn.readNetFromDarknet
@sundharsk May I know the Python and OpenCV version you are working with ?
@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.
Try with the latest version of OpenCV. That should solve the issue I hope.
@arunponnusamy Now New error is coming " error: (-2:Unspecified error) Cannot determine an origin framework of files: in function 'cv::dnn::dnn4_v20190122::readNet'"
how do I update OpenCV?
May I know the Python and OpenCV version you are working with ?
Using Raspberry Pi 3 and Python3
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'
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 .
Can you please tell me how to update opencv?
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 .
3
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 .
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
Using Raspberry Pi
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 .
It should probably be the same.
I found another website, that usses pi 3b:
http://funofdiy.blogspot.com/2018/08/deep-learning-with-raspberry-pi-real.html
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).
Use pip install opencv-python==4.0.0.21 should resolve your issue
Upgrading opencv from 3.4.1 to 4.1.1 resolved this issue.
Download and install Latest OpenCV WHL file
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
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.
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'