YOLOv8: How to Train for Object Detection on a Custom Dataset | yolov8 custom object detection

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends and welcome to YouTube channel Freedom Tech and in this session what we are going to learn in this session we are going to create our own custom object detection model for YOLO V8 but before we move to our practical friends if you learn something from our videos please consider to subscribe our Channel okay friends thank you so much and let's get started so as I mentioned friends we are going to create our own custom object detection model for yellow V8 for that first you need to install latest opencv and yellow V8 on Windows machine this is what Windows 11 of course you can go with Windows 10 machine also so I already created the video how to install opencv and yellow V8 on Windows machine I will mention video link watch video and install opencv and YOLO V8 on Windows 10 or Windows 11 okay so for today's session I have created here a repository and the repository name is yellow V8 custom obj account okay so I will mention link you need to Simply copy and paste link inside the browser then go to the code then we are going to click on download zip and it will download our ZIP format folder so just go here show in folder then right click and we are going to extract our folder so just like extract and it will create our folder so this is what our folder yellow we had custom obvious account Main same folder again and inside that I have mentioned coco.txt file basically this is a blank file there is nothing inside right now we are going to mention our object name then this is what the IMG dot Pi is basically capture our object images using our USB web camera in real time and then this is what the main python script uh inside the script I have created the basic code for yellow V8 as I mentioned I have already created a video how to use yellow V8 for object detection with pre-trained model I will mention video link watch video and then you will get the idea how we can use yellow V8 filter and model with the help of opencv and python then this is what our Google collab file for training purpose okay so first what we are going to do we need our images for our model so we are going to capture our images so let's just open IMG dot Pi with our Tony python IDE okay and what we are going to do I have here Arduino IDE board then esp32 board and I have here a DC motor so this is the three objects which we are going to uh detect so we need here these three objects images so simple this is the code with the help of this code we are going to capture a live images so max frames is equal to 30 it means it will capture each object 30 frames if you want to go with more then you can simply mention the number so let's say if I mention here one three zero one Thirty then it will capture each object 130 images means it will capture Arduino ID 130 images esp32 130 images DC motor 130 images so right now we are going to only mention here 30 images for each object for Arduino then esp32 and then DC motor then cm2 dot embrite this is the command which basically save our images inside our folder so we need to create here a new folder so basically what we are going to do we are going to create our new folder inside our repository the repository which we clone or we can say which we download so this is what our repository yellow we had custom obj account main here we are going to create our new folder so new and folder name folder let's say IMG this is whatever folder name okay and then right click and copy as a part because we need to mention here our path so here this is basically our object name Arduino so this is what our first object and here this is the full path okay so we are going to remove this old path okay and we are going to mention our new folder path so just remove it okay and just piss means I'm going to press here Control Plus V from keyboard that's it and then remove just double quote over here and that's it okay and this one also so now this is whatever folder path okay see in C we have users feed fold uh freed folder then downloads folder yellow we had custom obj account main this is whatever repository inside that we have again same folder name then we have IMG folder and inside that we are going to first create our Arduino Arduino board 30 images so for that we need to mention here our object name Arduino so if I want to capture esp32 so I am going to Simply remove Arduino and I'm going to mention here esp32 then it will capture esp32 all 30 images so simply we are going to first start with our Arduino so let's say Rd no okay now what we are going to do I have connect my USB camera with Windows machine so when we run our code when we run our script our USB web camera will start it will capture the live frame so what we want to do we want to Simply move our Arduino IDE board in front of the USB camera in different different angle slowly then it will capture a different angle Arduino ID images so now I will start a code foreign as you can see I have captured Arduino IDE board 30 images okay so if I open our folder so just open file manager inside downloads we have our yellow V8 custom object account main this is what our IMG folder and as you can see we have captured here Arduino IDE all 29 images okay now simply what we are going to do we are going to change our name object name so here I am going to mention esp32 so now we are going to capture esp3230 images Okay so let's just start our code foreign file manager downloads then our folder same folder and IMG folder and now here it is as you can see we have esp3229 images also we have our Arduino ID images so now what we are going to do we are going to capture our DC motor 30 images so let's just change esp32 with DC motor okay so if I save the code and if I run the code so friends we have done we have capture our DC motor images also so again in file manager downloads same folder IMG and here it is as you can see this is what our last object image 29 images with DC motor so we have done with data now what we are going to do we are going to use here a roboflow for training purpose okay so now we are going to Simply open our roboflow so friends as you can see I have opened here a roboflow website roboflow.com then just click on sign in and you need to sign in with your Gmail ID okay so here I have already signed in with my Gmail ID so here we are going to create a new project then we need to select object detection bounding box because we are going to use here yellow V8 with bounding box and then what we are going to detect here so let's just say Electronics then project name so let's just mention project name yellow V8 custom obj hyphen detect YT this is whatever project name you can mention any name simple so create a private project then here we need to now upload our folder the folder uh where we have our all images okay so simply I am going to open downloads yellow V8 custom obj account okay so this is what our folder IMG simply we are going to drag and drop so just drag and drop that's it as you can see it's now processing so this is whatever all images simply click on Save and continue so friends done so now here what we are going to do we need to assign our images so let's just click on assign images here you need to mention uh your name or you can mention any name and you then you need to mention the Gmail ID your Gmail ID as you can see I have mentioned freedomtech and this is what GMail ID simple so just click on assign images now it will assign the images that's it we have successfully assign our images now we are going to draw a rectangle on our images basically we are going to create here annotations okay so as you can see right now annotated zero and unannotated all our images so just click on first image then it will open this kind of page here we are going to select the first bounding box method so select it and then we are going to simply draw a rectangle on our object which is our Arduino as you can see I have draw the rectangle and here we need to mention our class name means our object name so our object name is basically Arduino that's it click on Save the next same way just draw a rectangle on the object same name because this is the same class Arduino save next draw rectangle save next image okay so this is how I am going to draw a rectangle on our Arduino image then we are going to move on over esp32 then we have our DC motor so let me first draw the rectangle on our Arduino board so friends we have done with our Arduino board now as you can see we have here DC motor so let's just draw a rectangle on our DC motor and here we are going to again change the class name so DC motor DC motor simple save next again draw a rectangle save next draw a rectangle on our DC motor save next so this is how I am going to draw a rectangle on our DC motor so friends as you can see I have done with DC motor now this is whatever esp32 so let's just draw a rectangle on USB 32 and here we are going to mention our new class which is esp32 then just click on Save go with next image same way draw rectangle esp32 same class next image draw rectangle same class save next image so this is how I am going to draw a rectangle on our esp32 board so friends we are done with drawing rectangle okay I have completed our last image now simply click here and as you can see we have completed our images now simply click on ADD 90 image images to data set so just click on there and then we are going to click on ADD images done now click on generate new version now here add processing step click on continue augmentation click on continue There is no need to change anything over here click generate click on generate now it's generating our data set done now we have done with our image processing now we are going to open our Google collab so friends I have opened Google collab so click on upload click on choose file and select our file from our repository yellow V8 custom okay so just select click on open done we have open our Google collab file then go to the runtime then click on change runtime type select GPU over here click on Save and then click on connect so friends as you can see we have connected so we are going to now run our cell one by one so first cell just click on here done now we are going to install our ultralytics package so second cell so friends done as you can see we have successfully run our next cell so now move to next one just scroll down and here from ultralatics in Portola now we are going to import our modules so just click on here done now we are going to run our next cell so here with the help of our by default print model as you can see yellow V8 and PT we are going to test our yellow yellow V8 simple so for that we are going to use a roboflow doc dot jpeg image with the help of yellow V8 and Dot PT which is pretrend model so just select next cell click on here so friends we have done so if I scroll down and this is what our image and from image as you can see we have dog dog and we have person that's it so now we are ready and if I scroll down so here we are going to uh now we need our data set so for that we are going to install Robo flow and we are going to use our roboflow code so for that again we are going to move on our page which is roboflow and here export as you can see click on export then select the format so format is basically yellow V8 that's it and then select the show download code and then click on continue it will generate the code that's it as you can see this is whatever code so from roboflow import Robo flow just copy okay just copy it copy like this way open our Google collab and this one from roboflow we want to delete and just paste our own code which we copy from this page as you can see your download code so just copy and paste here that's it now simply run the code so friends as you can see we have done so if I click here on the folder as you can see we have here data set folder because we create a data set folder so data set we have yt1 then we have test folder then we have our images and as you can see we have Arduino DC motor and esp32 board images simple so we have done with our data now we are ready and we are going to Simply create our own custom model so last cell just run here we are going to create a 100 epochs so just run our last code and it will create our own custom model so it will take some time it will basically create a 100 epochs so it will take some time meanwhile I will pause video so friends as you can see we have done we have create our own custom model so our model is basically save inside runs detect and train folder so just we are going to click here folder and let's just make like this way so runs detect and Trend so as you can see we have a runs folder just click here then we have detect folder so just click then we have train folder selected and then insert the trend folder we have weights and we have our model best DOT PT select here click on download now it will download our custom model so friends as you can see we have download our model best DOT PT so select show in folder and we are going to Simply move our model inside our repository so just right click click on Cut and this is what our repository yellow we had custom Mobile account main open same folder and just paste our custom object detection model base dot PT now we are ready and I am going to first minimize the browser and all other things okay and this is what our Sony python ID and we are going to open our now main script which basically we are going to use for object detection purpose so just go file click on open and then a test this is whatever main python script okay so now I am going to close the IMG dot Pi because we have done with IMG dot pi so this is what our basic code I am not going to explain all things because I have already explained all these things in the video okay in previous video basically so here it is as you can see I have mentioned yellow V8 dot PT this is our print custom model so here we are going to mention our best DOT PT model because we have now our own custom model base dot PT which we move inside our same repository so base dot PT then we have uh we have here basically our rectangle as you can see we have our rectangle then we are going to use here our camera so cap is equal to C2 dot video capture 0 is basically for uh one camera because I have here only one camera okay so we mentioned our own custom model so we are ready basically and now we are going to run our code so let's just save the code and if I run the code and friends as you can see it started our web camera and here it is whatever Arduino board okay so we have here error basically and the error is y because inside our inside our Coco dot TX there is nothing okay so that is why it says index is out of range so what we are going to do because there is nothing inside right now in coco.txt file it's completely blank so we are going to comment our C because our c is basically a class it will read our class names from our text file which is coco.txt okay so I have comment class list and here what we are going to do we are going to mention here a d d is basically our object ID our object ID so we have object ID because we create our own custom model so it will create by default with each object and their ID so we have ID so D is there so I have mentioned here D as you can see I have removed this C because right now we do not know the class class how we want to mention the class 0 is for what 1 is for what and then second is for what so we need the idea when we mention our class ID okay so I have comment the C and then I have mentioned here in the put text method I have mentioned D so D is basically our object ID okay so if I save the code if I run the code so friends as you can see you started our camera and as you can see we have here Arduino board and on Arduino board we have ID as you can see there is a zero 0 okay top left corner we can see there is zero so zero is basically our Arduino IDE uh ID okay so then we have here esp32 is detected esp32 and as you can see on top left of our rectangle Corner we have two so two is basically the ID for esp32 then we have here our DC motor as you can see is detected the DC motor so DC motor uh on DC motor as you can see we have one so 0 is basically our Arduino IDE board and one is basically our DC motor and two is basically our esp32 now we can mention our class names inside our coco.txt file so just open coco.txt downloads and same folder and this is what our coco.txt so 0 is basically our Arduino okay then one is basically our DC motor DC motor and the second is basically our esp32 so esp32 that's it now we have our class names inside our coco.txt now we can simply just click on Save now we can simply mention over here our c is basically our class names so we can uncomment our c so if I save the code if I run the code and and now as you can see on the top left corner there is a class name which is Arduino and as you can see we have here esp32 on left corner top left esp32 then we have here a DC motor on top left corner there is a DC motor so this is our friends you can create your own custom model for your own custom object remember one thing I have create here only 30 images in real scenario you need more images for better object detection purpose okay I hope you will learn something from this video we'll meet our next video till then thank you take care and bye
Info
Channel: FREEDOM TECH
Views: 4,526
Rating: undefined out of 5
Keywords:
Id: FrK8FfWc4P8
Channel Id: undefined
Length: 24min 43sec (1483 seconds)
Published: Mon Feb 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.