YOLO v3 EASY METHOD | OpenCV Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey everyone welcome to my channel in this video we are going to learn how to run one of the most popular object detection algorithms Yolo version 3 the method we will use is one of the easiest ones as it does not require any external installations we will write the code from scratch and go step by step with detailed explanation I have played videos on a weekly basis so don't forget to subscribe and hit that notification valve so you don't miss out on any of the upcoming content so let's get started so Yolo has gained a lot of popularity over the years and the reason for that is that it is a real-time detection method this means that not only we will be able to classify an object but we can also locate it and extract the bounding box that encloses the object and of course we can detect multiple objects at the same time so there are multiple methods to run Yolo three and the one we will be using is basically one of the easiest methods since it does not require any external installations we just need OpenCV and numpy so that is the first thing that we will be doing so we will go to our Python project we will click file we'll go to settings and over here we are going to import OpenCV OpenCV - and you will click install and then again you will go to numpy and you will click install so I have already done that as you can see I have numpy and OpenCV so then we are going to import them so we will right here import CV - and then we will import numpy as NP now the first thing we will do is we will create a while loop so that we can get the frames of our webcam so to do that right here cap is equals to C v2 dot video capture so we will put the index of the one over here now this value of one I am writing here because I have two cameras connected to my PC and if you have a laptop which does not have any other webcam connected you should put at zero or if you have just one webcam connected you should put 0 as well so most cases you should put 0 but since I have multiple cameras I am putting 1 ok so then we are going to write while true and over here we will write success an image is equals to cap dot read this will give us our image and it will tell us whether it was successful to retrieve or not and then we can simply write CV 2 dots I am show and over here we can write here for example image as the window name and then we can write image as the image that we want to display and the last thing we need is the CV 2 dot white key because we want to delay it and we will delay it for let's say one millisecond so let's run this so I will right click here and I will run this and I did not get anything let me turn on my camera again so let's run this again and there we go so now we have the webcam feed and you can see that we have a car that we wanted to TechEd so the next step is basically to load the yellow 3 model now since it was trained on the koku datasets we will first collect the names of our classes and we can simply do this by writing a list of all the names of the classes so we can for example say here classes and then we can write the names of each class now the thing is that we have 80 different classes and writing them all manually will take a long time so what we can do is we can use the koko names file to actually extract all these names so let's drag it in so this file you can find it on my website so we can simply drag it in and it will place it direct in our main directory so if we double click this you can see that we have all the names of our classes starting from person right up to toothbrush and you can see that we have 80 different classes and you can see we have many different types of objects like food cake orange we have cutleries like knife fork and then we have even animals sheep or scat so we have a little bit of everything well not everything well most common objects so then we will go back and what we will do is we will import all these names and we will store it in our list now this list we will call it class names and this will be an empty list and the path we will define for our cocoa names will be classes file is equals to cocoa names cocoa dot names and this is basically a text file so now we are going to open this text file and we will extract all the information so we will right here with open and then we are going to write classes file and then we will write that we are going to read it and this is a text file and then we will say that as F and over here we are going to write glasses class names is equals to F dot read and then we are going to write dot our strip and then we are going to write new line and then again dot splits and again new line so all this does is it extracts all the information based on new lines and what we can do is we can print it out to see if we are if we have collected it properly so class names and we can run this and if we open this up and you can see here that we have person bicycle car motorcycle and all the way up to toothbrush so one more thing we can do we can write here print and we can write here length of class names and we can rerun this and there you go so now we can see that we have eighty different names and all of them are stored in our class names so here are the names of all the classes in case you are wondering you can save this as an image so that you can find different objects so the next step is basically importing the model files and what we have is we have two main components one of them is the architecture of the network and then the other one is the weights sometimes both of them are combined in one file like in the tensorflow save model method but in this case we have them as separate so we are going to find our configuration file that has the architecture details and then we are going to find the weights file that has all the trained weights inside of it so to do that we can go to the Yolo website here you can see that we have all different types of weights and configurations so here you can see that Yolo version 3 320 now 320 just means this is the size of the image so it's 320 by 320 then we have 416 then we have 6 0 8 then we also have tiny now as you can see that if you are using a lower resolution your frame rate will be faster now if you are using 4 16 you will get 35 and if you are using 6 0 8 you are going to get 20 frames per second and if we use tiny then we will get a very fast speed of 220 but that will come with the trade-off between accuracy so our accuracy will decrease a lot we will have much less detections but our speed will be much higher so something like raspberry pi or Jetson nano can use Yolo tiny version now what we have to do is we can just click this and download them and what we will do is we will use the 320 and we will also use the tiny 320 we will use for general purpose to run throughout our tutorial and the tiny we are going to use at the end to see how fast we can detect and what are the frame rates that we can get so once the weights and the configuration file is downloaded we can just drag them in so here we have the configuration files of tiny and 320 as I mentioned before so I will drag them all in and there we go so have the two files for 320 and the two files for tiny so if we just open up the configuration file what we see here is basically the architecture and the parameters so for example you can see here we have the learning rate then we have the maximum batches steps and all these parameters that are required to run our network and then we can see the individual convolutional layers and we can see their parameters as well for example the number of filters and then we have destroyed the paths even the activation functions so you can see all of these over here so this is it for today's video in the next part we are going to load in our configuration and weights file and after loading them in we are going to run a forward pass on our network using our webcam image and once we have that it will output us the bounding boxes and then we can draw them out and see which objects did we find so if you liked the video give it a thumbs up and I will see you in the next one
Info
Channel: Murtaza's Workshop - Robotics and AI
Views: 104,844
Rating: undefined out of 5
Keywords: yolo v3, yolo object detection, yolo algorithm, yolo object detection code, yolo object detection python, yolo ai, yolo algorithm explained, yolo algorithm github, yolo object detection tensorflow, yolo darknet, yolo machine learning, yolo tutorial, yolo detection, yolo deep learning, yolo image recognition, object detection, darknet yolo, yolo opencv, yolo v3 opencv, yolo, deep learning, opencv, python, darknet, dnn, cv2.dnn
Id: GGeF_3QOHGE
Channel Id: undefined
Length: 11min 50sec (710 seconds)
Published: Fri Jun 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.