Episode 3 | How to Train Ultralytics YOLOv8 models on Your Custom Dataset in Google Colab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in this video here we're going to see how we  can train a custom object detection model with   YOLOv8 from Ultralytics we're going to see how  we can set it up we're also going to see how you   can label your data with a specific tool you can  lose use like whatever tools that you want how can   we act like export it into the YOLOv8 format  import into a Google Colab notebook and then   we're going to train our own custom optic texting  model with YOLOv8 so let's now jump straight into   Google Colab notebook let's see how we can set  it up it will be down in description here under   the video so you can use it on your own custom  data set so first of all here we're basically   just going to set up our Nvidia SMI just to see  what GPU we're running on if you want to use the   GPU make sure that you go up to runtime change  random type and make sure that right like have   chosen a dpu as the hardware accelerator so  yeah we have done that now we should be able   to call this Nvidia is a my command here we go  we can see the information about our GPU right   now this is just like the standard GPU in a Google  Colab notebook again you can use the free version   as well and you can run this fine and train  your own custom YOLOv8 model from Ultralytics   so now we're just going to pip install Ultralytics  here so now we can see that we've installed   Ultralytics in our environment now we can go down  and install YOLOv8 or basically just set that up   so from Ultralytics we're going to import the YOLO  model there we go now we have imported the YOLO   model from Ultralytics now we basically just need  our data set so I'm using like roboflow in this   video to go in and label my data set you can use  whatever tool that you want I have the data set   here let me just go in shortly to show you guys  that so I just have a data set with a number of   different cups then I've just labeled it here with  this annotation tool I'm basically just drawing   boundary boxes around it so you can just drag the  tool draw a bounding box around the object and   then choose whatever class that you want to like  have your object in after we've done that we can   then go in and Export our data set so I have some  versions already generated we hit export data set   and then we can select the format we're going to  go with the YOLOv8 format from Ultralytics then   we can hit show downloadable code so we just get a  code snippet and we can just copy paste that into   our Google colab notebook so I've already copy  pasted it here you first of all you just need   to copy paste in your API key then when we run  this we act like just download our data set and   then we'll have our data set in our Google colab  environment and then we can just directly train   our yellow V8 model on that so now we can see that  our data set has been downloaded we should be able   to go over into our folder we can see we have  this cup detection version two free we can see   we get a test set validation set and also a train  set so yeah we just have some test images we also   have the labels here so this will basically like  be the pounding boxes we have the label and then   we also basically have the top left corner and the  bottom right corner so this is the YOLOv8 format   from Ultralytics if you go down to the data here  I just want to make sure that we actually have   the correct path because we're using this in a  Google colab environment and we actually need to   directory for our image just so I'm doing to copy  paste that there we go and we also have our train you probably also need to do this here because  we're using a Google home app environment you   can also have your data set in a Google Drive  and then just connect to your Google Drive then   we basically have the path to our test set train  set and also our validation set we're just going   to save it and now we should be able to run it  directly in our Google collab notebook so now we   have this yellow command we're going to set the  task to detect for optic detection then we also   have this mode we set that equal to train because  we want to train our own custom YOLOv8 model now   for update detection we can choose which of the  yellow models that we want to use in this example   I'm going to go with the media model and now we  also just need to specify the location to our data   set so that will be the path to our data dot yaml  file that I just showed you and then we also need   to specify the number of epochs and image size  of the images that we actually train our model on   so now we can just directly go in and train our  YOLOv8 model so now we can see the training has   started for a custom YOLOv8 model they're just  going pretty fast because we're using the GPU here   in Google collabs now we can go into the metrics  that we get while our model is training just to   verify that we actually learn whatever you want to  I usually look at the mean error position so that   is probably like the most important parameter we  both have the mean air position of 0.50 and also   0.50 to 0.95 in intervals of 0.05 and those should  act like be increasing over your number of epochs   and ideally they should be close to one okay so a  custom uv8 model is now done training we can see   that we end up at our mean out position of 0.50 at  around like 0.81 82 and we also have like a meter   position of 0.50 to 95 of around 0.5 you can just  directly go in and download the weights from here   so in the next video I'm going to show you how we  can export these weights and basically just create   another instance in our own custom python script  with a yellow V8 model and then use the custom   trained one instead of a pre-trained one and also  how we can run live inference with our own custom   trained yellow V8 model so here we're basically  just going to plot the confusion Matrix we can   see that it acts like does a pretty good job with  our detection so ideally we should have all the   values here in the diagonal in our confusion  Matrix let's take a look at the train results   so these are all the graphs from our training  results for the metrics so we can see that the   mean air position 0.50 is increasing now we can  go ahead and take a look at the validation we can   choose the best model that we have at like  train and we specify the data set location   for our validation set and then it will just do  validation on images that the model hasn't trained   on before still look fine on our validation  set even though that these images have never   been seen by the model before let's now do the  prediction mode so I'm directly just going to   have a follow running through all the images  that we have in our detect and predict folder   there we go now we should be able to see all the  predictions so sometimes we made some predictions   but here we see that we're basically detecting  like all the cops with the correct labels here   we made some detections here we get some nice  predictions again pretty high confidence score   and we're only using the medium model so this is  how you can train your own custom YOLOv8 object   detection model so thanks for watching this  video here I hope to see in the next one it'd   be really exciting to run it live on a webcam  I hope to see in that video guys bye for now
Info
Channel: Ultralytics
Views: 65,136
Rating: undefined out of 5
Keywords: Ultralytics, AI, Artificial Intelligence, Object Detection, YOLOv5, YOLOv8
Id: LNwODJXcvt4
Channel Id: undefined
Length: 6min 1sec (361 seconds)
Published: Wed Jul 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.