Object Detection in 10 minutes with YOLOv5 & Python!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone my name is rob and today we're going to be using python to do some object detection using yolo v5 if you've never heard of yolo before it stands for you only look once and it's an open source package for doing object detection it comes with pre-trained models so it can do some object detection just out of the box you can also fine-tune it on your own data set if you want to do custom object detection i first came across yolo v5 when working on some kaggle competitions with object detection and it really currently is the state of the art there is a lot built into it that makes object detection just easy to do so we're going to walk through that and see how it goes today okay so here i am on the yolo v5 github repository you can see that it's a pretty active repository and they do have description here of what it is and have some official documentation to get started with it the first thing we actually need to do is clone this repo now i'm working on my desktop machine which is a linux machine running ubuntu 2004 and i also have two gpus in this machine that the yolo v5 will use to predict it also uses pi torch as the back end where all the models were trained and we will actually set up a new environment here that will run yolo v5 and have all the correct packages installed so i'm switching over here to my handy terminal and i'm in my directory where i like to clone my repositories and all i'm going to do is run this git clone here now it's recommended too that you have anaconda installed right now i i have anaconda installed on this machine and that'll let me create a brand new conda environment for yolo v5 so what it uh says to do next is just a cd into this directory where i cloned and if i do lctr we could see these are all the files from this github repository that we have cloned and then i'm actually gonna uh conda create uh with the name yolo v5 so i'm going to create a fresh new conda environment where we can install all the required packages so i just do that by doing connor create dash name i named it yolo v5 and i do need two dashes here in the name and i'll type yes to install all these dependencies okay so in order to activate this conda environment i just do conda activate yolo v5 activated in this environment and you can see because it says yolo v5 i also ins made sure i installed python 3.8 because the docs for yolo v5 do say it needs at least three seven it looks like so now that i'm in here i can just pip install all the requirements that are in this requirements text if you want to just look in the requirements text these are all the packages that it will install and it'll make sure i install all the right versions so this might take a little while because it's going to have to download some of the wheels if it's your first time installing these packages and it needs to run through and install them all okay so it looks like it's done installing them all so i'll just clear this screen if you look over in the repo in this detect dot pi we could see that it actually can be called just from python with some arguments so by default it will pick certain weights to use so yolo v5 comes in different sizes let's look and see what sizes of the weights that we have as options yeah so they're shown here yolo v5 the smallest is n and the largest is x and it looks like there's even a new one efficient debt version of it and what else are we gonna get it we're gonna need to provide it the source now i wanna provide it this my webcam to see if it will run directly on my webcam and we just provide the number where the webcam is associated so if you only have one webcam you'll be putting in zero here and we'll see how that that works and we're not actually providing any data to train on so we don't have to worry about this that's all we really need i think okay so i think i have it working here the command that i needed to run was just python detect and then i'm using source five which is my second webcam and i have a green screen here behind me so it's going to show the green screen when it loads up let's try running this detect and see how it works we can see that it is using the small version of uh yolo weights but there we are so you can see me there's a person here's my oh it thinks my fingers are carrots thumbs up uh let's hold up let's take off my glasses is it no glasses tennis racket all right not perfect not perfect um phone cell phone it's good at that uh maybe a cup cup okay yeah that's pretty good and you can see the confidences are shown on the side of the image so it's drawing the bonding box and showing the side but if you wanted to pull out just the the bounding boxes you could do that as well or store any information from yellow b5 by going into the source code cool so we're going to kill that and let's try to load the larger weights because the larger weights are going to mean that it performs more accurate and it's might be a little bit slower but it's going to perform better so what we need to do to get the larger weights is run python detect and then feed in the yolo v5x weights and then give it the same source now you can see it's actually downloading these weights fusing the layers all right and now we're back to my object detecting you can see the chair it sees the corner of the chair it knows this is a comp a lot better does it think my fingers are still no it's pretty good about my fingers maybe if i just hold my hand no it thinks i'm a person cell phone this is just working on the default pre-trained weights but if you wanted to does it know this is a microphone but you can make it more customizable by fine-tuning the training on a different data set that's pre-labeled there we go look that's pretty good it's pretty confident of all the things now let's try to run it on video data set so i do have this data set which is a video footage of a bunch of different cars driving around and i'm used this for a different youtube video that i created on working with video data but let's try to run this object detection on this video and see how it works we're going to call this again but instead of giving it a source we're going to give it the desktop mp4 file okay so it looks like it's running and it's detecting people bicycles cars so what it's doing here is it's running now on this data set it has the number of frames that it's gone through of the entire video and the number of people that it sees cars these are just some of the labels coming out here printed to our command line so it looks like you can provide a view image like this in order to actually view the images as its processing yeah there we go it's a little bit slower but it is working we see that it's detecting all these different cars and objects even detecting the traffic light which is really impressive so if i kill this now i can um change other settings like the confidence threshold and the iou threshold so if we only want it to show objects that it's very confident of it's defaulted to 0.25 but let's change that confidence threshold to 0.9 and run that there now it's detecting much less because the threshold that it needs to detect in order to show needs to be at least 0.9 let's do 0.5 okay that looks pretty good and then there's also something called an iou threshold and this basically means uh it's it will suppress any objects that it detects that overlap each other so iou has to do with the overlapping of two detected objects let's do 0.9 for the iou threshold is 0.5 so what's happening here is when we set the iou confidence to be really low it won't allow any boxes to be overlapping each other very much it'll just suppress any object detection that overlaps with another object detection so by turning this off and setting it really high will allow for a lot of overlapping boxes and let's do one last run with a really low confidence threshold and a high iou threshold there we go so this is a lot of different boxes and even this car that it's detecting in the lower right side is very low confidence but it's displaying it because we've set that confidence threshold so low thanks for watching this video it's a short introduction to using yolo v5 both on a webcam and processing videos for object detection if you enjoyed this video please give it a like and subscribe and i'll see you in the next video
Info
Channel: Rob Mulla
Views: 156,953
Rating: undefined out of 5
Keywords: Object Detection with YoloV5 & Python in 10 minutes!, object detection, deep learning, yolov5 custom object detection, machine learning, artificial intelligence 2022, yolo object detection real time, object detection deep learning, object detection project, yolo object detection on video, object detection with python, real time object detection yolov5, python yolo object detection, object detection yolo python, object detection for beginners, yolov6, yolov5
Id: fu2tfOV9vbY
Channel Id: undefined
Length: 10min 44sec (644 seconds)
Published: Tue Jun 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.