arunponnusamy / object-detection-opencv Goto Github PK
View Code? Open in Web Editor NEWYOLO Object detection with OpenCV and Python.
Home Page: http://arunponnusamy.com/yolo-object-detection-opencv-python.html
License: MIT License
YOLO Object detection with OpenCV and Python.
Home Page: http://arunponnusamy.com/yolo-object-detection-opencv-python.html
License: MIT License
How to train customs image ? Can you share Sample code?
i am getting this error, though i have implemented right path
hi,
When I try to run this code ,there is error like this:
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
E:\Anaconda\envs\opencv-env\lib\site-packages\IPython\core\interactiveshell.py:3275: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
How can I solve this issue?
Please tell me if you know this problem.
Hi,
I am trying to detect the objects in Grayscale Images without changing it to RGB format. I changed the channels=1 in the Config file you have given. Please help me with this.
Hi
Thanks for your sharing.
I have no issue with the yolov3 weights and yolov3.cfg but I got the following issue with Yolov3_tiny.weights and Yolov3_tiny.cfg.
cv2.error: OpenCV(3.4.3) /Users/travis/build/skvark/opencv-python/opencv/modules/dnn/src/darknet/darknet_io.cpp:507: error: (-215:Assertion failed) separator_index < line.size() in function 'ReadDarknetFromCfgStream'
Just wonder if you have any idea?
Hi @arunponnusamy , your work is very useful, thank you!
Is it possible to include video and stream video supports also?
I get this error
python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.
weights --classes yolov3.txt
Traceback (most recent call last):
File "yolo_opencv.py", line 93, in <module>
draw_prediction(image, class_ids[i], confidences[i], round(x), round(y), round(x+w), round(y+h))
File "yolo_opencv.py", line 36, in draw_prediction
cv2.rectangle(img, (x,y), (x_plus_w,y_plus_h), color, 2)
TypeError: integer argument expected, got float
so I changed this line
98 draw_prediction(image, class_ids[i], confidences[i], round(x), round(y), round(x+w), round(y+h))
to
draw_prediction(image, class_ids[i], confidences[i], int(x), int(y), int(x+w), int(y+h))
and then it solved
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)
Hi,
I can't manage to make this code work because of numpy and opencv-python are not working. I got the "Importing the multiarray numpy extension module failed" error. What is your configurations of those package and what is your version of python ?
After running the given command to run the script , the command prompt hangs and no response in observed
For getting more accuracy in faster-rcnn , which parameters i have to tune (tuning parameters). please anybody provide the solution for that problem, actually my model is working but the problem is getting less accuracy and some miss classifications are happens , so please kindly provide solution for getting high accuracy in the model.
Thanking you!
Error:- -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES
detect.py: error: the following arguments are required: -i/--image, -c/--config, -w/--weights, -cl/--classes
can you please solve this error
D:\...\YOLOobject-detection-opencv>python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt Traceback (most recent call last): File "D:\...\YOLOobject-detection-opencv\yolo_opencv.py", line 63, in <module> outs = net.forward(get_output_layers(net)) File "D:\...\YOLOobject-detection-opencv\yolo_opencv.py", line 28, in get_output_layers output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] File "D:\...\YOLOobject-detection-opencv\yolo_opencv.py", line 28, in <listcomp> output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] IndexError: invalid index to scalar variable.
Mac OSX 10.14.1 (18B75)
Traceback (most recent call last):
File "yolo_opencv.py", line 98, in
draw_prediction(image, class_ids[i], confidences[i], round(x), round(y), round(x+w), round(y+h))
File "yolo_opencv.py", line 39, in draw_prediction
cv2.rectangle(img, (x,y), (x_plus_w,y_plus_h), color, 2)
TypeError: only length-1 arrays can be converted to Python scalars
Hello,
I am trying to use your code for running detection of yolo v1.
I use python 3.5
I use opencv 4.1.0
The error occurs in line 57:
net = cv2.dnn.readNet(args.weights, args.config)
It says:
cv2.error: OpenCV(4.1.0) /io/opencv/modules/dnn/src/darknet/darknet_io.cpp:668: error: (-212:Parsing error) Unknown layer type: connected in function 'ReadDarknetFromCfgStream'
I took the weights and config from the original Darknet.
I tried weights and cfg for yolov1, as well as for yolov1 tiny, but the same error happens for both.
On the other hand, when I tried weights and cfg for yolov3, it succeeded.
So, does cv2.dnn modules are not compatible with yolo1? Is that the problem or anything else?
Thanks!
I ran the code and got this error:
cv2.error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-6uw63ony\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_v20201117::readNetFromDarknet'
Any idea? Do I have a version incompatibility?
python 3.6.8
opencv-python 4.5.1.48
Hi,
i am confused about the scale parameter setting to 0.00392 in cv2.readNet. How to get this figure? Could you please explain.
thanks a lot
When I execute the below command on Python openCV virtual environment, I am getting an error.
$ python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt
Error Logs:
Traceback (most recent call last):
File "yolo_opencv.py", line 59, in
net = cv2.dnn.readNet(args.weights, args.config)
AttributeError: module 'cv2' has no attribute 'dnn'
net = cv2.dnn.readNet(args.weights, args.config)
AttributeError: module 'cv2.dnn' has no attribute 'readNet'
Traceback (most recent call last):
File "yolodetect2.py", line 98, in
draw_prediction(image, class_ids[i], confidences[i], round(x), round(y), round(x+w), round(y+h))
File "yolodetect2.py", line 39, in draw_prediction
cv2.rectangle(img, (x,y), (x_plus_w,y_plus_h), color, 2)
TypeError: only size-1 arrays can be converted to Python scalars
ubuntu version 16.04
python version 2.7.12
opencv version 4.1.0
hi,
i've tried to use an other image (this one : https://www.actu-environnement.com/images/illustrations/breves/32181_fb.jpg)
when i run yolo with
python yolo_opencv.py --image trafic.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.py
i get this error
Traceback (most recent call last):
File "yolo_opencv.py", line 52, in <module>
with open(args.classes, 'r') as f:
IOError: [Errno 2] No such file or directory: 'yolov3.py'
yolo work with dog.jpg
Did you know how to fix it?
Hi Arun,
I recently came across your code. I am using it in a project I am working on. I needed to detect only persons in the room. Is it possible to detect only a person using the object-detection code?
i want to run your code but this error accuring :{
Hi @arunponnusamy ,
I might not make sense, so I apologize beforehand. I understand that the DNN module provided here is just for running the images. But in case I want to train the model and check the outcome myself. Or to put it in a better way; what if I would want to make changes to the existing YOLO model to either improve the results. How do I approach? Could you please suggest on how to go about?
trying to run this code getting error in this line
outs = net.forward(getOutputsNames(net))
Help please :)
E:\YOLOV3\yolo-custom-object-detector-master\python>python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights darknet19.weights --classes yolov3.txt
usage: yolo_opencv.py [-h] [-c CONFIG] [-w WEIGHTS] [-cl CLASSES]
yolo_opencv.py: error: unrecognized arguments: --image dog.jpg
I've done everything that is required in README, but once I put python yolo_opencv.py --image dog.jpg --config yolov3.cfg --weights yolov3.weights --classes yolov3.txt
in Terminal I get the following error:
Traceback (most recent call last): File "C:\Users\.....\yolo_opencv.py", line 50, in <module> outs = net.forward(get_output_layers(net)) File "C:\Users\......\yolo_opencv.py", line 20, in get_output_layers output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] File "C:\.....\yolo_opencv.py", line 20, in <listcomp> output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] IndexError: invalid index to scalar variable.
I've tried experimenting with i[0] - 1
(like putting i[0]
or i[1] - 1
) but to no avail. Am I doing something wrong? Can someone help, pretty please?
(I'm using PYCharm latest version (as of 04.11), just in case)
Thank you in advance!
I managed to run the inference script fine when using readNet, but now I want to use readNetfromDarknet to use the GPU. I have everything installed and running for using the GPU. However, I get this error
Exception has occurred: error
OpenCV(4.3.0-pre) C:\gitLocal\opencv\modules\dnn\src\darknet\darknet_io.cpp:601: error: (-215:Assertion failed) separator_index < line.size() in function 'cv::dnn::darknet::ReadDarknetFromCfgStream'
Any help would be appreciated. Thanks!
usage: ipykernel_launcher.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES
ipykernel_launcher.py: error: the following arguments are required: -i/--image, -c/--config, -w/--weights, -cl/--classes
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
C:\Users\adith\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3333: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
error 2:
image = cv2.imread(args.image)
NameError Traceback (most recent call last)
in
----> 1 image = cv2.imread(args.image)
NameError: name 'args' is not defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.