helmet detection using yolov5 | YOLOv5 training with custom data | yolov5 custom training colab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends and welcome to YouTube channel Freedom Tech energy session what we are going to learn in this session we are going to take a safety helmet with the help of Euro V5 basically we are going to create our own custom model for yellow V5 which detect safety helmet so before we move to our practical friends if we 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 we are going to create our own custom object detection model for YOLO V5 which detect a construction site worker safety helmet okay so for that first you need to install latest opencv then Sony python ID then YOLO V5 on Windows 11. I have already created the video how to install Sony Open CBD and YOLO WiFi also we need here a label EMG so how to install all this basic thing on Windows 11 I have already created the video I will mention video link watch video and install all these things so I have done with all these basic things so for today's session I have created here a repository and the repository name is yellow V5 safety helmet I will mention link copy and paste link inside the browser then go to the code click on download zip it will download our ZIP format folder okay so now simply go here click on show in folder this is what our folder so just right click click on extra call again click on extract and inside that we have a text file and inside the text file we have images for training purpose also we have our main video file with the help of this video file we are going to detect our object means we are going to detect a worker safety helmet okay so this is whatever python script the inside that I have mentioned a basic code so first we need our images and our videos so simple write the click to the text file click on open and first link is for basically downloading our images so open browser paste link adjust it enter click on download because I already use the link that's why it say a save so you you can see here download okay so just click on download and it will download our folder okay IN Zip format so just go here click on show in folder so this is whatever folder so now just right click click on extra call again click on extract that's it we have our images inside that I have share all images if I make a large icon as you can see we have here images so now what we are going to do we are going to Simply move this folder inside our main folder so just click on Cut go to the downloads and our main folder is yellow WiFi safety helmet main again same folder and inside that we are going to paste our images folder then we need our video file so again open our download.txt file copy the second link which basically for downloading our video so just open browser open new tab paste the link and just hit enter click on download now it will download our video in zip format so done friends we have successfully download our video file so just go here again click on show in folder this is what our ZIP format folder so right click and click on extract all click on again extract and inside that we have our video file so just cut and go to the downloads and our main folder which is yellow WiFi safety helmet hyphen main again same folder inside that we need to paste our video file simple so now what we are going to do we are going to train our images so simple we are going to open our thony python IDs open Tony python ID and here we are going to select python 3.9 because label EMG is not working with python 3.10 it will give us error so we need to change the python version so I already explained all these things in previous video as I mentioned I will mention video link then you will get the idea so here we are going to select run configure interpreter and here we are going to select python 3.9 exe click on OK so now we change our python version inside our Tony python ID so again go to the tools open system shell and here we are going to mention label EMG command label IMG label IMG so we open our label IMG open dir and downloads folder yellow WiFi safety helmet main again same folder and this is what our images folder select folder so we select our images folder change save folder again go to the downloads same folder same folder and again image images helmet folder click on select portal done now here we need to select yellow create rectangle box and we are going to draw a rectangle box ok so here we need to mention a class name so safety safety hyphen helmet okay safety hyphen helmet this is whatever object name click on Save next image create rectangle box and we are going to draw a rectangle box here click on OK click on save so now I am going to train all the images Step by Step means I am going to draw a rectangle on our objects okay so friends we are done with training okay this is what our last image and I have draw a rectangle simple so now we are going to close our label EMG software close the CMD shell and we are going to change again our python version with our by default version so go to the Run config interpreter and here we are going to select the first option which is by default python 3.106 okay so we have done now what do you want to do minimize just Tony and open file manager and downloads folder and this is whatever main folder yellow WiFi safety helmet Main same folder and this is what our image images helmet folder inside that we have as you can see we have our data and we have our images okay so now what we are going to do if I make here a small icons okay then as you can see classes and all the all training uh training data and text format and this is whatever images simple now we are going to create a new folder a data folder and inside that we are going to create images and labels and inside images and labels we are going to create again new to folder which is training and validation so let's just go outside so we are now basically inside yellow V5 safety helmet hyphen main this is what our main folder where we have our images helmet folder so here we are going to create our new folder create new and click on folder and mention the name data data okay and inside that again we are going to create a new folder which is images okay first folder and again second folder which is labels labels okay so now go inside images and here we are going to create again new folder so first one is basically training training and the second one is validation validation same way inside data labels here we need to again create a two folder so first one is training and second one is validation okay so we create a folder inside our main folder which is yellow if I save T helmet hyphen main so inside yellow V5 safety helmet hyphen main we create a data folder inside that we create labels folder images folder images folder inside that we create validation and terrain folder same way for labels training and validation now what we want to do we want to copy and paste all the data from our images helmet to our data images labels training validation okay so just press Ctrl a and copy all things go here you will if I safety main helmet and we have our data folder images folder training folder just paste all the things paste it then again go to the images inside validation paste all things okay then again go to the data now labels training paste all things okay then again labels validation paste all the things okay so we successfully copy paste all the data inside data labels validation okay then data levels training okay then data data images validation then data training and all the things we copy okay so now what we want to do we want to create a zip folder format for data so right click WinRAR at to Archive click on zip click on OK and now it will create a zip format folder okay so now what we want to do we want to Simply move our data folder on our Google Drive so friends I have opened Google Drive so right click click on file upload and we are going to upload our ZIP format folder so data click on open now it's uploading our data.zip file on our Google Drive so meanwhile we are going to open our Google app and here we are going to close all my old sessions so just click on yes and now we are going to upload our file so click on choose file again go to the downloads in folder your Lo-Fi safety helmet hyphen main again same folder and inside that we have our Google collab file okay so click on open so it's now uploading our Google collab training file on our Google cooler so now what we want to do we want to go inside runtime then change runtime type here we are going to select GPU click on Save then click on connect so friends we successfully connected now if I go here on Google Drive so we successfully upload our data.zip so we have done now we are going to Simply run our code one by one on our Google collab so first we need to install your lobby file so just run first code done now scroll down and now we are going to connect with our Google Drive so click on second code connect to Google Drive we need to give permission so select Gmail ID scroll down click on allow now it will Mount our Google Drive on our Google collab scroll down just click on unzip it will unzip all our images so done now we need to click on here folder then yellow if I train then yellow V5 and we are going to mention our classes name inside our data set yml so just double click and it will open data set yml like this way here this is whatever data set yml so here we are going to mention our new class name so let's just mention like this way okay safety helmet okay safety helmet and here also I am going to mention safety helmet okay safety helmet then just hit enter and press Ctrl s it will save our data set yml done now we are going to Simply run our last code which will create our model so just scroll down and this is whatever last code just click on here so friends as you can see it started our training 0 by 99 so it will take some time meanwhile I will pause the video so friends we have done we have completed our training process and now our model is saved inside run straight exp folder remember one thing here it will take little bit more time okay so just wait for completing our model creating process okay so we have completed our process now go here you will if I train YOLO V5 folder and as they mentioned runs folder so we have here runs folder then train folder then exp then we have weights and we have here base dot PT this is whatever custom model so we are going to download our model so just click here click on download now it will download our base dot PD so friends we have download our model as you can see base dot PT so just click here show in folder and this is what our model so we need to move our model inside our folder so just right click cut and this is what our folder yellow file save helmet hyphen main again same folder and inside that we are going to save our model so just click here so we successfully save our model now what we are going to do first we are going to close our browser okay now we are going to open our main dot Pi with the help of Sony python ID so go here then Tony go to the file click on open and then downloads and our folder which is yellow WiFi safety helmet hyphen main again same folder and our main dot Pi click on OK OK so now first what we want to do uh we are going to use our custom model so for that I have mentioned here custom and then we need to mention the path so this is the path variable so we want to mention the path for our base dot PT okay so we are going to create here a variable path is equal to in single code we are going to copy our path so so what we are going to do we are going to open our file manager and then downloads and our folder which is yellow WiFi safety helmet Main and here we have our base dot PT so we are going to copy the path so just click here and so this is what our path so copy it open Sony python ID and here we are going to paste the path okay just terminate so it's not basically copy so again we are going to go here copy and open Sony python ID and here we are going to paste so we have copy the path so we need to remove if we have here double code so again we are going to mention like this way so this is the path so now here what we want to do we want to change this slash okay so we are going to change this slash with forward slash okay so let's mention here forward slash this is what backslash so we are going to change the backslash with forward slash just change it and here also okay and at the end we are going to mention our model name so which is best DOT PT okay and here cap is equal to C2 dot video capture we need to mention our video file name so our video file name is basically inside our yellow fire safety helmet main our video file name is helmet okay so we are going to mention helmet dot MP4 in single code helmet dot MP4 okay so it will start our video file it will not detect our helmet because we want to call our model but we are going to just check our video file is perfectly working or not so just save it and if I run the code and as you can see this is what our video file okay we have here a construction site the worker are working and they were helmet the safety helmet here it is we have helmet okay so our video is perfectly working our basic code is ready now we are going to call our model okay so let's just call our model after where we resize our frame here we are going to mention results is equal to our model variable our model variable okay this one which represent our custom model so resource is equal to model inside that we need to pass our frame simple and then we are going to mention frame again frame is equal to NP Dot squeeze NP dot squeeze and inside that we are going to mention results Dot render results dot render like this one simple that's it so if I save the code and if I run the code and now as you can see friends our model is perfectly working it's detecting a safety helmet okay is detecting safety helmet here also we have two safety helmets as you can see is still detecting the helmet safety helmet here also we have three safety helmets here also we have two Softail mates so friends as you can see we create our own custom model with our data with our images okay and we successfully detect a safety helmet of course you can use your own images for this project also okay so I hope you will learn something from this video we will meet our next video till then thank you take care and bye
Info
Channel: FREEDOM TECH
Views: 10,249
Rating: undefined out of 5
Keywords:
Id: wvfjeLQMZOk
Channel Id: undefined
Length: 20min 30sec (1230 seconds)
Published: Thu Dec 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.