yolov4 tiny custom object detection | yolov4 tiny raspberry pi | yolov4 tiny object detection

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends and welcome to YouTube channel freedomtech and in this session what we are going to learn in this session we are going to configure YOLO V4 tiny version on our raspbian OS Bullseye 64-bit version we are going to create a custom model for YOLO V4 tiny okay 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 configure yellow view for tiny on Raspberry OS bold size 64-bit version means we are going to create our custom model for YOLO V4 tiny simple so for that first you need to install latest opencv on Raspberry OS boot size 64-bit version I will mention video link watch video and install opencv on raspin OS Bullseye 64-bit version okay then for today's session I have create here a repository a repository name is Yolo V4 tiny r54 I will mention the link inside my description box copy and paste link inside the browser then go to the code copy the link from here copy it and we are going to Simply clone our repository so run the command get space clone and just paste a link of our repository just hit enter it will clone our repository okay so now we have our repository now first thing first what we want to do uh we are going to train our images so we need here label EMG software okay so for that we are going to open our Repository so our repository is yellow before tiny R Pi 4 okay and inside that as you can see I have created here a text file and the text file name is label EMG install dot txt so right click Text Editor and we have here two commands so we need to Simply copy paste these two commands inside our terminal so First Command copy open Terminal and let me first clear the screen and then simply we are going to paste our first command just hit enter it will install Pi beautify hyphen Dev tools on our raspberry OS Bulls 64-bit version then our second command which is label EMG software so copy the second command paste inside the terminal and then just hit enter that's it we are done with label EMG software I already installed both packages okay that's why it says the requirement is already satisfied so this is how you need to install these packages simple now what we want to do we need our data okay so we are going to use here our USB web camera for our data or we can say for our images okay so in this session we are going to detect basically Arduino ID then RPI picot then mask image and without mask image okay so simple so for capturing images I have created here IMG dot Pi script which basically create images okay with the help of our USB web camera of course you can use your Raspberry Pi 4 camera module also so just right click IMG dot pi and click on Tony python ID it will open our IMG dot Pi with the help of our Sony python idea as you can see it's open so it's creating 70 image 7070 image for each class means if I want to detect the Arduino so it will create Arduino 70 images then Pico 70 images then without mask images 70 also with mask 70 images so this is the frames maximum frames okay you can simply increase as per your requirement you can mention 170 0 you can mention 200 if you want to go with more data you can mention 1000 also okay so we are going to train only 70 image per class okay right now simple so first we are going to start with Arduino so here what we want to do it will create the the images inside YOLO V4 hyphen tiny and obj folder so we need to create this folder okay so first what we want to do open again file manager and here we are going to create Lolo V4 tiny folder okay so YOLO V4 hyphen tiny so open and we I am now inside slash home slash pi as you can see Slash from slash Pi so here right click new folder YOLO V4 hyphen tiny click on OK yellow before hyphen timing we have here our folder okay and inside that we are going to create again new folder which is obj so just right click and again create new folder which is o b j or nothing to create inside basically yellow before tiny we are going to Simply create a outside okay obj not inside yellow before tiny so just click here and create a new folder there is no need to create again I am going to explain here there is no need to create obj folder inside yellow before tiny folder because we want to save a zip format file okay so just create obj folder okay when we capture our data then we are going to train our data or we can say we are going to basically create the rectangle on our data and then we are going to create a zip file obj dot zip and the zip file which you want to save inside yellow Before Time okay there is no need to create a Omega folder inside yellow before tiny that's it so we have created here a two folder we will be for a tiny okay right now there is nothing okay and then we create a obija folder so inside obgo folder we are going to save all our data okay so here what I am going to do I am going to change this yellow before tiny basically I am going to remove yellow before tiny so we need to mention the path okay so slash home slash Pi obj is our folder inside slash on slash file and then we are going to save our images simple so let's just start with Arduino so I need to delete without mask and here we are going to create our first class so Arduino which is our class name Arduino Rd no okay so this is what our class name okay simple so let's just save the code and we are ready now I'm going to Simply start web camera then we are going to Simply move our Arduino board in front of USB camera in different different angle okay so simple so I am going to start our web camera okay so friends as you can see we have created a data for Arduino so if I open our obj folder and inside that as you can see we have 70 images for Arduino okay now same way we are going to create another 70 images for Pico board so let's just change our class name with pico Pico okay so save the code and now I am going to start again code and it will capture our 70 images with pico board okay so friends you have successfully capture our picot board image now with mask so with mask okay with face mask okay so with mask we are going to capture again 70 images okay so save the code and if I run the code so friends we are done with with marks now without mask so without mask this one is our last class okay so again save the code and if I run the code so friends as you can see we have successfully captured our images okay now what we want to do we want to draw a rectangle on our classes so we are going to Simply close our Tony python ID and just open terminal and we are going to run our label EMG software so run the command like this will label label and just press tab button it will auto complete our Command as you can see label EMG just hit enter and as you can see we have our label EMG software so click on open dir click on open dir and our dir is obj so select it click on choose and it will open our images as you can see then change save dir and save di or obj just click on choose that's it now here we need to select yellow then create rectangle box and we are going to simply draw a rectangle box on our Arduino and label EMG we are going to mention the class name Arduino click on OK save next image create rectangle box draw the rectangle box on our object click on OK save next image create rectangle box draw rectangle box click on OK save image okay so now let me train Arduino images okay then I will start a video so friends we have done with our Arduino now this is what our Pico board so again click on create rectangle box and we are going to draw a rectangle box on our picot board and the label we are going to mention Pico simple click on OK save next image create rectangle box again draw the rectangle box on Pico click on OK save next image create rectangle box draw rectangle on picot boards and save so now I am going to train all our Pico images okay so friends we are done with pico board now mask image okay so with mask so create rectangle box and we are going to draw a rectangle on our mask and we are going to say like this way with mask okay with hyphen mask click on OK save image next image create rectangle box again we are going to draw a rectangle box on our mask click on OK save next image okay so this is how I am going to Trend or we can say this is how I'm going to draw a rectangle on over with mask images okay so friends we have done with with mask images now we are going to draw rectangle box on over without mask images so create rectangle box and we are going to make like this way without marks so here we are going to mention without mask Okay click on okay save next image create rectangle box without mask click on OK save next image create rectangle box again without mask click on OK save rectangle box so this is how I am going to train our last image which is without mask okay so friends we are successfully train our all images now simply we are going to close our label EMG software now what we want to do if I open file manager and this is what our object folder and inside that we have our images and their text file okay simply what we want to do we want to create a zip file for our obj folder okay so what we are going to do if I run over here LS command so this is what our obj folder and we have our obj folder inside slash on slash Pi okay so run the command like this way let me first clear the screen is it hyphen small R then the zip file name so obj dot zip and the folder name obj slash star it will create a zip content which we have inside our object folder okay so zip space hyphen small r space obj dot zip this is what our file name and then space obj slash star just hit enter as you can see it's creating a zip file with the data which we have inside our obgo folder so if I open our file manager just a minute okay so here it is as you can see we have here obj dot zip file so simply what we want to do we create here YOLO view for a tiny folder okay and right now there is nothing so we want to Simply move this obj dot zip just click cut inside our yellow before tiny paste that's it now friends what is the next step we we have here our repository which we just cloned so our repository name is Yolo view for tiny r54 okay and inside that inside that we have obj data obj names and YOLO V4 hyphen tiny custom dot CFG file okay so right click object data text editor and here it is as you can see by default the classes is 4 because I have right now four classes suppose if you have two classes you need to mention here two classes if you have ten classes you need to mention here two or ten classes not two basically ten classes okay so classes is basically how many classes you have means how many objects which you want to uh detect or which you basically train Okay so this is the things which you want to change here only okay so classes is equal to four because I have here only four objects okay four classes so classes four just click on file and click on Save that's it simple we are done with obj data okay then obj names right click Text Editor okay and here inside that we need to mention our classes name so as you can see I have mentioned the four classes first one is Arduino second one is Pico and another one is with marks and last one is without mask okay so this is how you need to mention your classes name or you can say your object names okay which inside a obj DOT names file that's it so we have done with object data we have done with obj names then YOLO V4 hyphen tiny custom dot CFG file okay so right click open with text editor and here what we want to do just scroll down scroll down scroll down okay and at the end as you can see YOLO at the end yellow okay and here the classes of course you need to mention your classes numbers okay so I have here four classes so I have mentioned here as you can see the number is 4 suppose if you have two classes so you need to mention two classes so right now we have here four classes so I have mentioned four classes then what we want to do the filters as you can see this is whatever your law let me make like this way I'm going to close with text editor just save it and right click roller for custom CFG and we have here I think I think it will open with okay so we have here numbers so it will get better idea okay so what you want to do just scroll down scroll down and here uh here as as you can see two seven zero line okay two seven zero line we have classes so here you need to mention your classes numbers if you have 10 classes you need to mention 10 if you have two classes you need to mention two okay so right now I have here four classes so I have mentioned four classes then here as you can see the filters so filters I have mentioned 27 so how to mention filters okay so if I scroll up here it is as you can see I have mentioned the main method for uh mentioning or we can say for creating the filter so filters is basically classes the number of classes which we have plus 5 multiplied by 3 means right now I have four classes okay so four plus five multiply by 3 27 that's why I have mentioned here if I scroll down that's why I have mentioned here in filters I have mentioned various filters this not this one basically okay not this one uh YOLO and here it is as you can see this one is yellow at the line 264 as you can see at the line 264 filters here you need to mention the number 27 okay with this method with this method the classes suppose if you if you have two classes so two plus five multiply by three then you need to mention here 21. okay so then here's as you can see right now I have four classes so four plus five then multiply by three it's become twenty seven okay so I have mentioned 27 so here also if I scroll up one more thing there is here it is also we have filters as you can see line number two one three filters 27. so line number 213 then the line number 264 filters and then line number two seven zero here you need to mention classes numbers okay so I have mentioned here method again I am going to explain here classes how many classes then plus five multiply by 3 then whatever the number you need to mention with filters simple so this is how you to mention changes inside yellow before high fit iPhone tiny custom CFG file simple so I am going to close all these things and we have done with changes now what we want to do we want to move this obj data obj names process dot pi and yellow for hyphen tiny CFG file inside our roller before hyphen tiny folder okay so we are going to copy and then you're looking for Iphone tiny just paste where we have our images means obj dot zip file inside that we have over all train images okay so then again our repository obj dot names copy go to the home you're looking for Iphone tiny paste again go to the home our repository then process dot Pi copy go to the home tiny you're looking for a hyphen tiny and paste then again go to the home same process then this time custom CFG so copy it home annually for hyphen tiny just paste okay so now we have here obj data obj names our images with zip object.zip then processes dot pi and yellow for hyphen tiny custom dot CFG file so we have done now what we want to do we want to Simply move our yellow for iPhone tiny inside our Google Drive so open Google Drive and here I am going to click here and click on folder upload as you can see click on upload so it will upload our folder so here just click on upload now meanwhile what we are going to do we are going to Simply open our Google collab okay so click on Google collab so friends as you can see I have open Google app click on upload choose file and our Google collab file is in our repository yellow for tiny r54 this is what our repository and inside that as you can see we have our collab file so click on open so it's now uploading okay so meanwhile what we want to do open again our Google Drive and we have successfully upload our folder yellow for hyphen tiny click on the folder okay and this is whatever data our files as you can see yellow before hyphen tiny hyphens custom.cfg then process dot Pi then this is what our data obj dot zip obj dot names and obj Dot data so we are now inside you know for iPhone tiny so here what we want to do we want to create a new folder so right click and click on new folder and here we are going to create a new folder and the folder name is basically training training okay just click on create so as you can see we create a new folder inside our YOLO before Chinese so if I go my drive rollover for iPhone tiny and inside that we have training folder that's it now what we want to do we want to go on our Google collab files then click on runtime type change runtime type select GPU click on Save and then click on connect okay now it's connecting okay just click on OK a notebook requires High Ram click on OK so friends we have successfully connect now just start with first code it will clone the darknet folder as you can see we have successfully cloned our Dark Net folder now we want to mount our Google Drive so click on here second code then connect to Google Drive we want to permit this notebook to access your Google Drive so click on connect to Google Drive then choose your Gmail ID then scroll down then click on allow okay as you can see it's now mounting our Google Drive so friends we have successfully Mount our Google Drive then our next code which is third code make changes in the make file so just click on here done with third code now fourth code it will build our Dark Net as you can see run make command to build Dark Net okay so it will take some time so friends we are done okay as you can see build.net process completed so just scroll down and we are going to run our fifth core so click on here done then now it will unzip our data so click on here copy the data set zip file to the root.net folder and it will unzip over data as you can see it's unzipping okay we have our all images okay now scroll down now copy the custom CFG file from the drive to the darknet CFG folder so click on here so next core copy the obj names and obj data files so that they are now in darknet and data folder okay so just run the code now same way process dot Pi it will copy inside the darknet folder run the code done now we are going to run our process dot Pi so click on here done now we need a rollover for hyphen tiny pre-trained weight so just click here it will download our yellow V4 hyphen tiny pre-trained weights okay so we have done now what we want to do we are going to Simply start our training okay as you can see train your custom detector so just click here so friends as you can see our process is started okay so it will take some time meanwhile I will pause video okay so friends uh our process is still going but if you go inside our Google Drive and we have here our training folder okay and now as you can see inside training folder we have here three weights file you're looking for hyphen tiny custom last weight then yellow for hyphen tiny custom best weight and the last one is as you can see YOLO before hyphoon tiny custom 1000 weights okay if you want to stop the training you can simply stop the training so if you want to go with more iterations you can simply continue or if you want to just go with a 1000 dot weight means we we completed here 1000 iterations okay so you can simply go with this weight okay yellow for hyphen tiny custom 1000 weights okay so simply what I am going to do I am going to Simply stop our code okay because we have our weights per so simply just I am going to close the Google collab okay and now what we are going to do we are going to Simply download our 1000 words as you can see this is what our weights file when we completed our 1000 iterations okay so simply just right click and just download and now our file will be download okay as you can see it's now downloading go look for tiny weights 1000 dot weights basically okay so it's downloading so if I go here click on show in folder and as you can see this is what our file inside downloads now what we want to do we want to Simply copy our weights file go to the home and where we have our repository we we have our repository inside slash and slash Pi YOLO for tiny r54 this is whatever repository just paste our weights file inside our repository that's it now I have already create the python script for detecting the objects our custom objects with our weights file okay so for that first what we are going to do we need here tensorflow main version and CV lip package okay so simply we are going to open our terminal let me clear the screen okay and we are going to install first tensorflow okay tensorflow main version not tensorflow Lite okay sudo P3 install sudo P3 install tensorflow and just hit enter it will install tensorflow on our Aspen OS bullsey 64-bit version I have already installed okay that's why it says the requirement is already satisfied then as I mentioned we need here a CV leap okay so run the command so do peep three install CV lib and just hit enter okay it will install CV leave on our raspberry OS bolt size 64-bit version which also I have already installed that's why it's a requirement is already satisfied so we need here tensorflow main version and civil package okay simple so we have done now we are going to Simply open our file okay so our file is basically test dot py as you can see inside our repository test dot pure so right click Tony python ID and it will open our test dot Pi inside our Tony python ID okay and as you can see uh from CV leap.object detection import YOLO then import CV2 okay then cap is equal to 72. video capture this is how we always call our web camera okay so then vets so vets is just variable so vets is basically our wet file so here what is our weights file name this is what our vets file name as you can see we have this one okay so right click rename and just copy the name copy it Sony python ID and here we want to mention that file name so delete and control plus b just paste that's it then config file you're looking for Iphone tiny custom CFG we have already the file inside our as you can see yellow before hyphen tiny custom.cog so we have our file already inside yellow for tiny rp4 yellow before hyphen tiny custom CFG okay then we have obj dot names okay so if I open again our repository then we have here obj dot names okay simple so we need to Simply mention our wet file name that's it so I have mentioned it okay as you can see that's it now then config is equal to our custom config file CFG then labels is equal to over object dot obj dot names then count is equal to zero okay then while loop then rate AMG cap dot rate this is how we always call our camera okay a cap then count plus 1 is equal to 1 why because I am going to skip here at 10 frames okay because we are working on Raspberry Pi 4 CPU version so we are going to skip some frames okay for fastest detection with yellow before tiny version okay so what that I have mentioned here count is equal to zero then it will skip 10 frames simple then we are going to resize our frame 680 is the width and 460 is the height then yellow is the variable okay so yellow is basically our yellow module okay so as you can see I have called here YOLO then inside that we need to mention our weights variable then config variable and then labels variable as you can see weights config and label then we have we will have here B box label and conf so B box label and cons is equal to Yellow dot detect objects okay our method okay YOLO dot detect objects then inside that we need to pass our IMG okay then cb2.m show IMG is equal to IMG okay and then what will be happen it will basically show us a detection okay so simple so if I save the code if I run the code and friends as you can see right now there is no mask and it says without mass okay so if I wear the mask and as you can see it says with mask okay with mask okay so we have here our Arduino board also so as you can see without mask also it's detected our Arduino board okay now we have here Pico board so if I show Pico board as you can see it's detected without mask facts and Pico board also as you can see so we have successfully create our own custom model for yellow for tiny and we detect our custom objects okay so I hope you will learn something from this video okay so I have shared the code okay so we will meet our next video till then thank you ticker and bye
Info
Channel: FREEDOM TECH
Views: 9,272
Rating: undefined out of 5
Keywords:
Id: jYtc5XTYLP0
Channel Id: undefined
Length: 31min 4sec (1864 seconds)
Published: Thu Nov 10 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.