Image Classification custom data train yolov8 in Google Colab for free | Computer vision tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey my name is Felipe and welcome to my channel, in this  video I'm going to show you a very easy way to   train an image classifier, this is going to be a  very easy and a very quick tutorial so let me show   you. We are going to work with Google colab, this  is a notebook in my Google colab, and we're also   going to work with Google Drive so please make  sure you create a directory in your Google Drive   in order to work on this project, now let me show  you the data we are going to use today or actually   let me show you the data I am going to use in  order to train this image classifier, I'm going   to work with the fashion mnist dataset which is  a very popular dataset in computer vision you are   going to find this data set a lot in different  computer vision related tutorials or actually   different image classification related tutorials,  this is a very popular dataset and this dataset   is comprised with many many different fashion  related items right, you can see these are   a few samples these are a few images of this  dataset and all of these images are fashion   related items, let me show you all the different  categories we have in this dataset these are the   10 different categories we have and you can see  these categories are t-shirt trouser pullover   dress coat sandal shirt sneaker bag and ankle  boot so once we train an image classifier with   this dataset we will be able to classify an image  into one of these 10 categories, so I'm going to   post a link to this dataset in the description  of this video so if you want to follow along this   tutorial you can just go ahead and download  exactly the same dataset I am going to use   today, now let me show you something which is very  important and it's how you need to structure the   data in order to work on this tutorial, so now let  me show you how to structure the data this is a   very important step so let me show you how to do  it, you can see I have two directories one of them   is called train and the other one is called test,  it's very important you name these directories   exactly like this one of them should be called  train and the other one should be called test, I   know this sounds like a detail it sounds like  it's a completely meaningless and unimportant   detail but trust me it's very important you name  these directories exactly like this, absolutely every   single technology you use in order to train an  image classifier or any type of machine learning   model is going to have its own requirements  regarding how to structure the data and in this   tutorial we are going to use ultrallitics version  of YOLOV8 so this is how we need to structure the   data in order to use YOLOV8, it's very important  you create two directories and it's very important   you call these directories exactly like this one  of them should be called train and the other one   should be called test... you could also call this  or directory differently you could call this   directory val, if you call this directory val is  because this is going to be the validation data if   you call the directory test this is the test data  but in order to keep things simple I invite you   to just call these directories exactly like this  one of the them is called train the other one is   called test if you're going to follow along this  tutorial then just create these two directories   and name these two directories exactly like this and  everything is going to work exactly the same as   it's going to work for me, so now once you have  created these two directories you can see that   within train and within test I have 10 folders and  these 10 folders are called, are named, exactly the   same as the categories we are going to classify  with this classifier remember I am going to use   the fashion mnist dataset and I'm going to  classify all my images into one of these 10   categories I have over here so this is exactly  why I have 10 folders within train and within   test and these folders are called exactly the same  as the categories I am going to classify all my   images into and let me show you a few examples now  if I open the sneaker folder you can see that this   is where I have all my images of the sneaker  category, you can see that this is the folder   where I have all the images of sneakers and if I  go up and I show you another example for example   t-shirt you can see that this is where I have  all my t-shirts and so on right so each one of   these folders has all the images of that specific  category so in order to structure the data into   the exact structure you need in order to train  this image classifier using YOLO V8 you need two   directories one of them is called train the one  is called test then within train and   within test you need as many folders as categories  you are going to classify and then within each one   of these folders is where you are going to locate  all of your data, this is all of your training data   and this is all of your test data, so once you  structure the data exactly like this the only   thing you need to do is to zip this directory  where you have located your train directory and   your test directory and then then the only thing  you need to do is to compress this directory and   to create this file I have over here which is data.zip  and then once you have this file the only thing   you need to do is to get back to your Google Drive  and you need to upload this file into your Google   Drive, in my case you can see that I have already  uploaded this file it's here data.zip so I'm not   going to upload this file again but please make  sure to upload this file into your Google drive   into the directory you have created in your Google  Drive in order to continue now let's get back   to Google colab, let's get back to this notebook  in my Google collab and let me show you how   to train this image classifier and remember this  notebook will be available in the GitHub repository   of today's tutorial so just take a look at the  description of this video and you are going to   find a link to the GitHub repository of today's  tutorial and this is where you are going to find   this notebook so the only thing we need to do now  is to execute all of the cells in these notebooks   one at the time and that's going to be pretty much  all in order to train this image classifier so I'm   going to execute this cell over here this is going  to take care of mounting our Google drive into this   Google colab and this is going to be pretty much  all we need to do in order to access the data in   our Google Drive, and this is going to be pretty  much all, now remember we have uploaded all of our   data over here in this file which is data.zip  we are going to copy this file which is in our   Google Drive we're going to copy this file into  this Google collab environment into this Google   colab instance, and then we are going to unzip all  the content of this file here right so it's very   important you change this value over here which  is the location of the data you have uploaded   into your Google Drive, you can see that now it  says train yolo8 image classification google colab   data.zip which is the the location of the data in  my Google Drive right you can see this is train   yolov8 image classification Google colab and the file is  called data.zip and everything it's in my root   directory in my Google Drive which is called my  drive which is exactly what we have over here, so   just make sure you change this value to whatever  location you have chosen for this file in your   Google Drive and once you have changed this value  over here the only thing you need to do is to   press enter and this going to copy this file into  your Google colab environment and then it's just   going to unzip all the content  of this file and that's going to be pretty much all,  okay you can see that we have extracted all  the content of this file into our Google colab   right you can see that these are all the images  into in our dataset and that's going to be pretty   much all so the next step in this process will be  executing this cell over here which is going to   install ultralytics which is the Python package  we are going to use in order to train this image   classifier and then the only thing we need to  do is to execute this cell over here you can   see that we are importing ultralytics which is  the python package we just installed and then   we are defining a new variable which is called  model and then we're just calling model.train and   that's pretty much all we need to do in order to  train this image classifier and please notice that   the data location is content data which is exactly  where we have copied all of our data over here   right we have extracted this zp file exactly here  so this is why we are specifying this as our data   location and then the number of epochs you can see I  have set the number of epochs in five so I'm going to   train this image classifier for only five epochs but  you can train this classifier for as many many   epochs as you want but in my case I think five epochs  are going to be enough in order to show you how   to train this image classifier so you can see  that this is the training process everything is   going just fine everything is just okay and now  the only thing we need to do is to wait until   this is completed and once your training process  is completed the only thing you need to do is to   get all the results from your training process  right you want to get the results you want to   analyze your model, you want to get the weights of the  model you trained and this is where all the results   were saved, in content runs, so the only thing you  need to do now is to execute this cell over here   and this is going to take care of copying all the  content in this directory into your Google Drive   and this going to be pretty much all in order to  get all these results right and please remember   to change this value over here to the location  of your directory in your Google Drive and   once you have changed this value over here the  only thing you need to do is to press enter and   it's going to take care of copying all the files  into your Google Drive now let me show you if I   go back to my Google Drive you can see that this  is the directory we have just copied over here   which is called runs and this is where all the  results were saved so this is going to be pretty   much all in order to show you how to train this  imagifier in order to show you a very very quick   and a very easy way to train this image classifier  but if you want to have a much more comprehensive   description of how to train this image classifier, if  you want much more details then I invite you to   take a look at other of my previous videos where  I show you exactly the same process, I show you   exactly how to train an image classifier using  YOLO V8, exactly the same process, but in a much   more comprehensive way and I show you much more  details and I also show you how to make inferences   with the model you trained, I show you how to analyze how  to evaluate all your training process, I show you a   much more comprehensive description of the entire  process so I definitely invite you to take a look   at that other video over there but for now this is  going to be all so thank you so much for watching   this tutorial my name is Felipe, I a computer  vision engineer and see you on my next video.
Info
Channel: Computer vision engineer
Views: 1,466
Rating: undefined out of 5
Keywords:
Id: mMKohUdGZJQ
Channel Id: undefined
Length: 11min 21sec (681 seconds)
Published: Sun Feb 04 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.