"Stay Safe on the Road: YOLOv8 Bike Helmet Detection Demo | Bike Helmet Detection with YOLOv8

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 vate for detecting bike rider helmet so 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 friends as I mentioned today we are going to create our own custom model for YOLO vate which basically detect a bike rider safety helmet so for that first open Tony python ID and we are going to install packages our basic packages so open CV hyphen python hit enter open CV hyphen python just click on install it will install our open CV hyphen python then we need ultral litics package just hit enter first package click on install install it will install ultral litic package then we need CV Zone package just click on CV Zone and as you can see the CV Zone computer vision helping Library just click on it and click on install that's it it will install CV Zone on our Windows machine this is Windows 11 machine of course you can use your Windows 10 machine also so uh first we need open CV hyphen python then we Ultra litics package then we need CV on package that's it so we have done with package installation so for today's session I have create here a repository I will mention the link inside the description box you need to Simply copy and paste the link inside the browser then yolow at helmet detection this is the repository name go to the code click on download zip and it will download our ZIP format repository as you can see it's now downloading so now simply open file manager downloads and this is what our repository right click wiar and and extract with the folder name and then this is what our repository same folder and inside that we have all our files so we have here our video file so let's just First Watch what is our scenario so let me start the video file this is what our video where we have a traffic where we have a biker and then as you can see we have here helmet also simple so as you can see there is a helmet there is a bike bike rider so our goal is to detect the helmet from this video so let's just start so for that first we need a data we need images so we are going to use our scenario means we are going to use our video for images so for that IMG dopy just click on and it will open IMG dop in our Tony python ID so here what we want we want to Simply mention our video file name so our video file name is basically H e2. MP4 so here video capture H e2. MP4 and then how many images we need so we are going to only train here 100 images of course you want to train more images for better performance so for this session I'm going to only Train 100 Imes so I have mentioned here 100 if you want 1,000 images you need to Simply mention 1,000 if you want 3,000 simply mention 3,000 it will capture the 3,000 frames so right now we need only 100 frames so 100 is our frames so I have mentioned here hundreds then here we want to mention the folder where we are going to save our images so right now this is what our repository so we need to create here a folder so right click new folder images so we create here a images folder so right click copy as a path and we want to mention the path over here from the images just remove all the things remove it and just press control+ V so this is what our path and here it is as you can see we need to remove this double coat and and here also here also remove the double code that's it now this is what our path this is what our images this is the folder and inside that we are going to save all the images name with person you can simply change your name let's just say helmet helmet so now it will save the images name with helmet and the extension is basically jpg so it will save it will capture 100 images and name of that images helmet and jpg is the extension and it will save inside our images folder so let's just save the code and if I run the code so as you can see it started our video frame and now it's capturing 100 images from our video frame itself so if you go here this is what our images folder and insert that as as you can see if I make view extra large icon so as you can see it's capture 99 images the 100 images so now simply we can use these images for database for training purpose so now we need now we have our images now we want to train our images means we want to draw a rectangle on our object so for that we need a label EMG so for label EMG we need python 3.8 version so simply go here Microsoft Store open it it will open our Microsoft store and then here we want to search python 3.8 as you can see python 3.8 and then this is the version python 3.8 and just click on install and it will install python 3.8 on our Windows machine because label EMG is work with python 3.8 for that we need a python 3.8 so just go to the Microsoft store and just search for python 3.8 and click on install it will install python 3.8 so I have already installed python 3.8 on my machine so now go to the Run config interpreter as you can see config interpreter and here we want to select the by default is basically python 3.10 so we want to select here python 3.8 as you can see python 3.8 exe so just select it click on okay and then you will see inside shell we have now python 3.81 version so here we are going to Simply install our label EMG so just click on run uh sorry not run go to the tools and open system shell and pip install label IMG pip install label IMG just click on enter and it will install label IMG so which I have already installed so command is peep install label IMG that's it so this is how you need to install label IMG first you want to download the python 3.8 with the help of Microsoft store then you need to go in run config interpreter here we want to select python 3.8 click on okay then go to the tools open system shell and then just run the command peep install label IMG peep install label IMG and it will will install label IMG so done we successfully install label IMG now just minimize Tony and now what we are going to do we want to Simply run our Command which is label IMG so label IMG label IMG just hit enter and it will open our label IMG now go to the open DI and we need to Simply go inside our images folder so our images folder is basically inside our Repository this is the images selected and as you can see we have our images change save di go to the downloads repository repository and images folder selected that's it done so now simply here we want to select a YOLO YOLO then create rectangle box and we want to draw a rectangle box on our object so in scenario we have helmet so we want to basically draw the rectangle on our helmet so like this way mention here class name so helmet again create rectangle box draw here helmet click on okay create rectangle box this is also helmet as you can see click on okay create rectangle box draw a rectangle on the helmet click on okay just save it go for next image create rectangle box draw rectangle box the helmet which is the class which we already mentioned so simply click on okay create rectangle box draw rectangle box click on okay create rectangle box draw it okay create rectangle box draw it click on Okay click on Save next image again same way just click on create rectangle box click on okay create rectangle box click on okay create rectangle box click on okay create rectangle box here also C on okay so this is how you need to draw a rectangle box on each helmet you need to Simply click on create rectangle box save it and just go for next image just go for next image as you can see just go for next image so here also just create rectangle box draw it on the helmet click on Save and this is how you need to draw a rectangle box on the helmet so I have already done with label EMG so simply I'm going to close all these things and I have already create here it is as you can see uh the text file where we have rectangle box and images it means we successfully train our data that's it so just go back now I'm going to delete the images folder because I have already trained the images so download and this is what my images folder which I have already trained so go inside the repository just copy paste so if I open as you can see 116 images and this is the images same as you can see the same scenario so we have done with image training now simply we want to create just open again downloads same repository so we want to create a folder and inside that we want to create images and labels folder and again in images and labels folder we want to create training and validation folder so let's just create a new folder so new folder and mention the name Freedom Tech Freedom Tech is the name because it inside our training file I have mentioned the freedom Tech folder so we need to create here a freedom Tech folder if you create any other name the the Google collap code will not work because I have mentioned the folder name inside the Google collap file which is freedom te simple so Freedom te is the folder open it again here we want to create a two folder which is images and another one is labels images and labels so we create Freedom Tech folder inside that we create a two folder which is labels and images now we want to go inside images folder and here also we want to create a two folder which is training and validation so right click new training and again new validation validation that's it it then go back again Freedom te so we create a folder inside images so we want to now create a folder in labels so right click new training and validation that's it training and validation in both folder in labels we create a validation and training folder in images we create a validation and training folder now simply go back where we have our repository and inside that images we have all our data so simply press cr+ a select it right click copy all the things and we want to paste all these things inside images training validation folder and inside labels training validation folder so go to the freedom Tech images training folder just paste it go back so we paste ins inside the training now we want to paste all these things inside the validation just paste it done go back Freedom te labels validation paste it labels training paste it done so Freedom Tech images folder validation folder we have copy paste all our data training folder we have copy paste all our data in images training we copy paste all our data in images validation we copy paste all our data again go to the back freedom take labels training we copy paste all the data labels validation we copy paste all our data so this is how you need to Simply copy paste all the data now go back and we are going to create a zip file so right click Freedom Tech vinar add archive then zip click on okay and it will create our freedom te. zip file so now we want to move this file on our Google Drive so friends as you can see I have open my Google Drive so right click file upload and go to the downloads then our repository yolow at helmet detection and we have our freedom te. zip click on and click on open it will upload our freedom te. zip so meanwhile what we are going to do we have our Google collab so simply click on upload browse and go inside our repository same way and this is what our file Google collab file simply click on open and it will upload our Google collab file on collab so we successfully upload our file now simply click on connect it will connect with GPU so friends as you can see we successfully connected so simply we want to run cell one by one so click on first cell then click on second sell it will install ultral litics package done scroll down from ultral litics import yolow scroll down now we we are going to cross check our ultral litics so it will basically download a image doc. JPEG and it will download yolow vn. PT model then as you can see result save inside run detect predict it means we successfully install YOLO V on our Google collap machine now simply we want to download our freedom tech. Z file so here it is as you can see this is the code code which basically connect with our Google Drive so let me check okay so our upload is completed so we are ready simply click on the cell click on connect to Google Drive and select your Gmail ID which Gmail ID where you upload your freedom tech. zip file so just select it allow and now it will down download it will basically mount it will not download basically it will Mount the Google Drive so as you can see it's mounted our drive so Freedom tech. zip is our file now next cell it will unzip our file so we successfully unzip our file go to the folder and data sets Freedom Tech is our folder and inside that images and labels we have all our data now here we want to create a data. yl file so just Freedom T here and select it and click on new file and we are going to create a new file which is data. yaml so mention the name data. yl data. yl and it will create a data. yl file just click on it it will open so we want to mention the code inside data. yml so if you open the repository downloads data.txt as you can see so just open it the txt file and this is the code simply copy it all the code copy it and open our browser and data. yml right click and just paste it this is what our code so right now we have only one class so NC means the number of classes is basically by default one and the name of class which we want to mention here as a helmet so just remove it and mention helmet if you have two class you need to mention number of classes two then you need to mention here your second class name second class name simple so right now we have here only one class so remove all the things and here one helmet is our class just control+ s save it close it and just run our next cell which basically create our model with 100 APO simple so just click on it now the process is started so friends as you can see our training process is started so it will take some time meanwhile I will pause video so friends our trading process is completed and our model save inside runs detect and train folder so just go here runs folder then detect folder then train folder and then we have weights folder so inside that weight folder we have base. PT our model so just click on it and click on download it will download our base. PT model so friends as you can see we successfully download our model so just minimize browser open file manager and then the downloads and this is what our model right click cut and just move the model inside our main repository paste it that's it now simply we want to create here our coco. txt file so first let's just open our main code where we have our detection our uo detection so I have mentioned full code inside our main ed. Pi simple as you can see this is the rectangle method because I have explain all the method in several videos so I have mentioned full code so now simply we want to create here a Coco 1.txt file so let's just open repository right click and then new and uh text file text document Coco 1.txt and inside that we have only one class so we want to mention simple helmet which is our one class just that's it then click on save it close so we have our Coco 1.txt file ready now simply we want to mention here our video file name which I have already mentioned and and model which is b. PT done so simply run the code oh because we change our python version we want to again go back with our main version so run config interpreter here it is as you can see we select 3.8 for label EMG so we want to select our by default version which is 3.10 now just start the code and as you can see friends it's detecting helmet we trained only 100 images and our custom train model is ready and it's detecting helmet as you can see it's perfectly working so let me show you here if I go with zero then we want to skip our frame one by one and as you can see it's detecting helmet simple here it's detecting helmet this one also helmet helmet so we are we use our a video file for images and then we we train the images and we create our own custom model with the help of Google collab and it's detecting helmet simple so this is how friends you can create your own custom object detection model for y for detecting the helmet I hope you would learn something from this video we'll meet our next video till then thank you take care and bye-bye
Info
Channel: FREEDOM TECH
Views: 6,751
Rating: undefined out of 5
Keywords:
Id: ARHjcG509jo
Channel Id: undefined
Length: 23min 51sec (1431 seconds)
Published: Sat Sep 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.