Raspberry Pi 4 AI acceleration with Coral USB | Google Coral USB on Raspberry Pi 4

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 friends in last session we successfully configure Google Coral USB X lat with Raspberry Pi 4 using latest Raspberry Pi OS book W 64-bit version so in this session we are going to create our own custom object detection model for Google Coral USB accelator and then we are going to detect our own customs objects 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 in last session we successfully configur Google Coral USB accelerator with Raspberry Pi 4 using latest Raspberry Pi book War 64bit version so if you don't know how to connect and how to configure or how to install all the software for Google code USB please watch last session video then you will get the idea how to configure Google Coral USB exelator with Raspberry Pi 4 for Raspberry Pi book War 64bit version operating system so as I mentioned today we are going to create our own custom object detection model for Google Coral USB accelator so before we start our today's practical let's just cross check if our last session code is perfectly work or not so just go to the menu programming open Tony and here we want to select our virtual environment which uh already there as you can see python 3.92 which is the required version for Google Coral USB exelator and as you can see this is what our repository we create a freedom Tech repository inside that repository we create a virtual environment and we install python 3.9.2 then we install Google Coral USB uh all the packages that's it and this is what our basic code this is what our 240 image size model A pre-train by default model so this is what our last session code let's just start the code and I have connect the USB web camera I connected USB web camera so it will start uh object detection with the help of our Google Coral USB exelator so friends as you can see our USB web camera is started and it's detected me as a person using Google Coral USB accelator as I mentioned we get here 8 FPS because same time I am recording on same Raspberry Pi 4 machine that's it so if you just if you just start normal USB accelator you will get 18 FPS 18 FPS simple so our last session code is perfectly working and we are ready we are going to create our own custom object detection model so let me close here tonyi python ID so for creating our own custom object detection model first we need our own database means we we need our own images then we uh we need label IMG software then we are going to use here our Google collab machine for create creating our own custom model so first we want our database so for that I have create here a new repository I will mention link inside description box you need to Simply copy paste the link inside your web browser then this is the repository name yellow V8 custom object detection Google Coral USB simply go to the code click on download zip and it will download our zip format repository just click on it as you can see we successfully download our repository so go to the file manager downloads and this is what our new repository right click extract here and this is what our folder right click to the folder cut and just move folder inside slome this one the home folder just paste it go inside and first as I mentioned first we need our images so for collecting images data we are going to use our USB web camera we are going to capture live images so IMG dop this is what our IMG dopy code for uh capturing images so first what we want here for capturing images we are going to use a normal python version means our by default python version so let's just open menu programming Tony and here we create our uh virtual environment and we select python 3.9.2 but for images again we want to go back with our by default version so just go to the Run config interpreter and here this is what our virtual environment for python 3.9.0 so here we want to select default version which is bin Python 3 click on okay and then as you can see we have now our by default python version which is 3.1.2 simple now just open our IMG dopy code from the repository we just download go to the home and this is what our repository yellow at custom object detection Google Coral USB main just select it click on okay and from this we are going to open IMG dopy just click on okay and it will open IMG dopy so of course we need open CV package we install open CV package for python 3.9.2 version but this is the default version python 3.1.2 so for this version we need to install open CV so just go to the tools manage packages and search for open open CV hy1 python hit enter first package then it will search for the package but before we start to installing the package one more thing friends one more thing just open our repository and here we have rpy 4. txt file as you can see rp4 this is normal text file just open with text editor and first before we install the packages we want to run this command this command the first one command sudo RM just copy it copy the command open Terminal and let me make a zoom in here zoom in zoom in zoom in I hope you all see clear so as I mentioned before we install any package with the help of Tony first we want to run this command this command which I have mentioned in inside RP 4. txt a normal text file just open with text editor and copy the First Command just copy it open Terminal and then just paste it and then just hit enter just hit enter that's it we have done then close text editor minimize terminal minimize all these things and again open Tony python ID go to the tools manage packages and search for open CV Hy python open C we hon python this is the package hit enter first package and then click on install now it will install open CV python on our Raspberry Pi 4 for latest python version which is python 3.1.2 so it will take some time meanwhile I will pause a video so friends as you can see we successfully install open CV python now we are ready and today our custom object is basically Rd Uno board so we are going to detect ardino Uno board and we are going to detect here esp32 board this is what our two object two custom object which we are going to detect with the help of our Google Coral USB accelerator simple so first object is ardin uno so we are going to capture here 50 image uh images of ardino Uno board and 50 images of esp32 board board so here it is as you can see I have mentioned Max frames 30 you can simply change the number how many number of images you want to collect for particular project so as I mentioned we are going to create 50 images for two objects our first object is basically ardino Uno board and our second object is basically esp32 board and then we are going to save all these images inside the same repository this is what our repository let's just create here new folder let's just say images images this is what our folder images and inside that folder we are going to capture all our images so right click to the images folder and then copy the path close it and here we want to mention the path so from images just remove all the things from images go back back back just remove it all the things and just press control+ V it will copy paste our new path New Path of our images folder here it is as you can see our repository is inside slome /py Yol custom detect detection object detection Google Coral USB hyphen Main and inside that we just create images folder and inside that images folder our first object is ardino uno so I have mentioned the image name is ardino uno then jpg G is basically extension and it will capture 50 image now when we start our code we want to Simply move the object means for this scenario I have here Ard Uno board so I need to Simply move Ardo Uno board in front of USB web camera in different different angle for collecting the our database so if I start the code it will start my USB web camera so friends as you can see we capture 50 images of our Ard no board so if I open file manager again our repository inside that we create images folder and as you can see we capture here ouro Uno board 50 images here it is as you can see this is what our AR you know Uno board as you can see I'm continuously moving Ardo Uno board in different different angle that's it so same way now esp32 so here simply change the ardin Uno with esp32 save it and now if I start the code I need to again move esp32 board in front of my USB web camera in different different angle that's it so if I open file manager go to the folder this is what our repository then we have our images folder so this is what our ardino images and this is what esp32 board as you can see esp32 so we successfully capture our images now we need our label IMG software so for label IMG software we need to install label IMG software so right now as you can see this is what our normal directory means if I run here PWD command we are now inside slom /p so here if I run LS command this is what our repository as you can see yellow V8 custom object detection Google Coral USB hyphen B this is what our repository we need to go inside the repository so C d space YOLO V8 and then just press tab button it will autocomplete our repository name then just hit enter now if I run LS command uh we have here label IMG Dosh bash script which install label IMG so we need to Simply run this label IMG Dosh bash script but first we want to give the full permit for this label IMG Dosh so here inside our repository as you can see right now I'm inside the repository we are going to run the command sudu space Cham mode sudu space CH mode or you can simply call it CH mode 775 this is the permission 775 then space and the script the best script which is label label IMG Dosh label just a minute uh label IMG Dosh then just hit enter if I run LS command as you can see now it's in green means we successfully Chang the permission now we are ready and just run the script bash space label IMG Dosh and then just hit enter it will install label IMG software on our Raspberry Pi 4 book War as you can see it's installing so friends as you can see we successfully install label IMG successfully installed label IMG now we are ready and we are going to open our label IMG software so if you run here let me first clear the screen if you run here or you can simply come out from the repository now there is no need to uh continuously stay inside the repository just run the CD command and come out from the repository clear the screen and now if you just type here l a b and if you press the tab button and as you can see it will autoc complete our Command this is the software command label and I is basically Capital so L A and press tab button l abl l and l a b e l and IMG as you can see if I press here let me show you again l a b e and just press tab button it will autoc complete our Command and if you hit enter it will open label IMG software so as you can see this is what our label IMG software just minimize terminal full screen label IMG software now we need to select our images directory so open DI and then inside Pi we have our repository and our repository is yolow V8 custom obj this is what our repository inside that we create images folder and inside that images folder we have our all the database so click on choose and as you can see this is what our image first image then just change save di mention the same uh same di so click on change save di go to the pi scroll down and our repository Yow at custom obj images folder and click on choose simple so we successfully mentioned open DI also we successfully mentioned chain save di now here Pascal V we just click on it and just change as a yolow we change as a yellow because we are going to create a yellow database then now we are ready click on create rectangle box and just move it and just draw the rectangle on our object which is ardino Uno and mention the name ardino Uno ardino Uno click on okay Save It Go for next image click on create rectangle Bo box then draw the rectangle box same object click on okay Save It Go for next image create rectangle box draw the rectangle box same same image same device same object you can call call it anything so same name are Uno just save it now if you open the repository and because we have inside our images as you can see we have image their text file image their text file image their rectangle text file so this is how this is how we want to install label MJ software and simply select yellow and draw the rectangle box on your objects so let me draw a rectangle box on ardino Uno images then I will same way draw a rectangle on esp32 board images simple so meanwhile I will pause a video so friends as you can see I have done with Ardo Uno now now this is what esp32 board same way just click on create rectangle box and draw the rectangle box on esp32 board and here again we want to mention our label IMG means our label for esp32 is basically esp32 esp32 click on okay Save It Go for next image create rectangle box draw a rectangle box on our esp32 board select esp32 click on okay Save It Go for next image create rectangle box draw the rectangle box on esp32 board select it esp32 click on okay save it so this is how I will draw a rectangle on esp32 board also meanwhile I will pause video so friends we have done with drawing rectangle on each image as you can see this is what our last image so we have done with 100 out of 100 images so it means we have done with our label IMG software now simply close the label IMG software and open Terminal and let me just clear the screen and what we are going to do here first let's just open our repository and go to the Y at custom object detection this is what our repository and inside images if you open our images folder as you can see we have image there text file and inside that text file we have a rectangle coordinates which we draw this is the rectangle coordinates as you can see so each image their text file each image their text file Aro their text file then we have esp32 image their text file it means we successfully complete our label IMG process now what we want to do just go back click on back and here in same Repository where we have images folder we are going to create a new folder so create a new folder mention the name Freedom Tech do not change the name mention same name folder Freedom Tech click on okay go inside Freedom Tech folder again here we are going to create two new folder so first one is basically images images click on okay right click second folder which is labels labels so we create Freedom Tech folder go inside Freedom Tech folder then here create two new folder first one is images and another one is labels now go inside images folder and again here we are going to create a two new folder first one is basically training training training and then second one is validation validation training and validation this is the two folder which we want to create inside images folder now go inside labels folder and here also we are going to create same to folder validation and training so right click training and validation done so so what we we want to go inside our repository so what we do here we create Freedom Tech folder we then inside Freedom Tech folder we create images and labels folder then we go inside images folder and here we create training and validation folder same way we go inside labels folder and here also we create training and validation folder now from images folder our images folder where we have over all the data just press crl + a and select all the data right click copy it all the data and go back go inside Freedom Tech folder images folder training folder paste it all the data go back same way inside validation folder paste it all the data go back then go labels folder same way go training folder paste it all the data go back same way where validation folder paste it all the data so just copy paste all the data from our images folder to Freedom Tech to images training and validation then from labels to training and validation copy all the data from our images folder now we have done now we need to create a freedom te as a zip file because we want to move that zip file on our Google Drive so just open rpy 4. txt file with text editor because inside that I have mentioned the command and this is the command as you can see this is the command so just open your terminal open it and go inside the repository as I mentioned just run LS command this is what our repository we need to go inside the repository so command is CD space yolow V8 and just press start button it will autoc complete our folder name or repository name now we are inside our repository and here is we have our fom Tech folder now just copy this command copy it second command open Terminal and then just paste it and then just hit enter it will create Freedom tech. zip file as you can see we have all the images so it will create all the data as a zip file so if you close all these things and here it is as you can see we create this folder as a zip file now simply open your your Google Drive and upload this Freedom tech. zip file on your Google Drive so let me open my Google Drive first so friends as you can see I have open my Google Drive so go to the new click on new then click on file upload and upload our freedom tech. zip so we have home folder our repository and inside that we have our freedom tech. zip click on open and now as you can see it's uploading our freedom tech. zip on my Google Drive so meanwhile we are going to upload our collab file so just open Google collab go to the upload click on browse and inside our repository inside our repository you at custom object detection Google collab USB this is what our repository and inside that I have mention our collap file for training purpose so just select it click on open and it will upload our collap file on our Google collab so friends as you can see we successfully upload our collab file on our Google collab so let just connect so go to the runtime then change runtime type and here select Python 3 then selective for GPU then click on Save and then just click on connect so as you can see it's now connecting so friends we successfully connected as you can see T4 now we are going to run our cell one by one so first sale just click on it first sale done now next sale here we we are going to install ultral litics and tensorflow version 2.13.1 just click on our second cell it will install all these packages which we mentioned so it will take some time so friend as you can see we have successfully run our second cell also so just scroll down and run next cell click on it from alrx import yellow done now we are going to cross check if our yellow V8 is perfect ly installed so for that just run next cell we are going to use your yo8 and. PT model and we are going to use a online image from roof flow.com so just click on it a next sale if we successfully install tics we will get the result means from this image we will get the objects so we done and as you can see from this image we have one person we have one car and we have one dock means we successfully installed ultral litics now just move on our Google Drive and here one upload complete it means we successfully upload our freedom tech. zip now just we want to mount our Google Drive on Google collab so just click on this cell as you can see we are going to mount our Google Drive so just click on the cell and permit this notebook to access your Google drive files so click on connect to Google Drive then select your Gmail ID then click on continue then here just scroll down click on continue and done now it will Mount our Google Drive on collab machine so friends as you can see we successfully Mount our Google Drive on our Google collab and as you can see this is what our freedom tech. zip file Freedom tech. zip now we want to unzip our file so just click on next cell it will create a data sets as a directory and inside that directory it will unzip our freedom tech. zip file as you can see ardino Uno esp32 so if you go here just click on this folder icon small icon we have data set folder and inside that we have our freedom Tech folder okay and then we have images and labels so for Freedom Tech here it is as you can see this is what our folder here just click on this three dot on the freedom Tech folder just click on this three Dot and click on new file and first we need to create here data. yl so just data. yl and and then just hit enter it will create a data. yl empty file then just double click on this file it will open our file like this way it is completely empty so inside this file we want to copy paste our data so just open the repository again youate custom object detection Google Coral USB hyen main this is what our repository and here inside that we have text file data.txt right click Text Editor and copy all the things copy it all the text copy it open collap file we open data. yl just paste it all the things which we copy here we want to select allow just copy paste all the things from our data. TST file copy paste inside data. yml just click on allow and then it will allow to copy paste the data and here as you can see the names our names is our object name is basically ardino Uno and esp32 so we need to change this surfing inside double code arino Uno this is what our first object ardino Uno then again comma again in double quod inside that mention ESP esp32 so this is what our two object Ardo and second one is esp32 and NC means number of classes is basically two so change one with two so this is how we want to mention our names our class names which is already know Uno and ESV 32 for this particular scenario and this particular scenario we have two classes so number of classes is two done now simply press here control+ s it will save our data. yl close it the close it the file then just scroll down scroll down and come to the next cell which is custom Training and here as you can see this will create our own custom model and here we are going to mention IMG SZ image size we want to mention here 240 240 mention 24 so because we will create here 240 image size model for our Google Coral USB simple so we are going to use yellow V at n. PT we will use here yellow at n.p model and then we will create our own custom model with with the help of IMG SZ 240 uh with 100 epox it will create our model and then we are going to convert this model with htpu do TF light so first let's just create our model so here it is as you can see I have changed the image size with 240 just just click on the cell it will start our training so friends as you can see one out of 100 means it will start our training simple it started basically our training 1 out of 100 to out of 100 so it will take some time meanwhile I will pause a video so friends as you can see we completed our training process and our model is save inside runs detect and train so just click on the runs then we have detect folder then we have train folder and inside that we have weights folder and then we have base. PT our model so we need to convert this model in htpu Dot flight format for that we have next cell as you can see this is what our next cell so here I have mentioned our best. PT path so this is what our best. PT path content runs detect folder as you can see the content folder then we have runs folder then we have detect folder then we have train folder then inside train folder we have weights folder and inside that we have best. PT so I already mentioned the path so don't change anything so this is is what the next cell where we convert our best. PT model with the format htpu htpu so we are ready so just click on the sell and it will convert our best. PT model with htpu dotf light format it started our process so it will take some time meanwhile I will pause video so friends we completed our process we success y convert our model in htpu dotf light and our model is save inside content runs detect train weights and base save model folder so go to the runs this one runs then we have detect folder then we have train folder then we have weights folder and inside weights we have your best save model folder so best save model and then our model name is best full integer Quant H tptf light so best full integer cont uh cont htpu dotf like this one as you can see if I if I click here so this model name is best full integer qu htpu dotf 3.27 MB so this is what our model so we have here three dots click on it click on download and it will download our custom model as you can see it's downloaded this one so just minimize all these things and if you go here in downloads folder we have our model so we need to Simply move this model inside our repository so right click selected the model right click and click on Cut and go to the home and here we have our repository yellow custom object detection and then just paste our model inside this repository simple our repository you custom object detection Google cor USB men and inside that repository I have mentioned test.py code for object detection with the Google Coral USB test.py now simply we have our Tony python ID and here because we changed the version with default one now again we need to go with our python 3.9 12 version so go to the Run config interpreter here select it /om slpy Freedom tech. VNV bin python 3.9 click on okay and it will change our python version as you can see now python 3.9.2 so just close untitle file go to the file click on open then go to the home our repository and open test.py open it test.py and this is what our by default model so we need to mention our new model so go to the Repository this is what our new model our custom object detection model just click on rename copy paste copy the name copy the name and then open Tony and this one the old model a default one model just remove it in double code just press control+ V and it will copy paste our new model name which is bful integer cont do cont hp. tfight just save it done and then just close all these things close it and here again uh our repository Yol custom object detection Google col USB Hy main here we need to create our text file where we will mention our class name our object class name so right click new file and Coco 1.txt Coco 1.txt this is is what our label file Coco 1.txt right click open with text editor and inside that we need to mention our classes name so our first first class is basically arjuno Hy Uno this is what our arjuno Uno and the next one is esp32 just mention just open uh create the new file open with normal text editor click on file and just save it close it as as you can see I have just right click click on new file and then create the new file name as Coco 1.txt right click to the file open with text editor and just mention our object name Ardo Uno is our first class and esp32 is our second class so we are ready and here inside our test file we need to change our coco. txt with Coco 1.txt then all the things are same just click on save it and just run the code so friends as you can see it started our frame and if I show here ardino Uno as you can see it's detected ardino Uno it's detecting ardino Uno board and if I show here esp32 it's detecting esp32 and we we got here FPS is basically 11 FPS so if I show again Ard no this one is Ard no and we have here esp32 both object as the same time both object as the same time esp32 and RD no no so friends we successfully create our own custom object detection model for htpu our Google Coler USB device so this is how you can create your own custom object detection model and you can uh detect your own custom object with the help of Google caller USB uh with Raspberry Pi 4 I hope you'll 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: 887
Rating: undefined out of 5
Keywords:
Id: fLL_j87ju08
Channel Id: undefined
Length: 39min 10sec (2350 seconds)
Published: Wed May 08 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.