Mastering YOLO V8: Object Detection and Hugging Face Deployment

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome to my channel codewell my name is hesamic Dean or you can simply call me Sam in this video we'll build and deploy a custom object detection model using ulo V8 and this the steps that we are going to follow first thing that we are going to do is install our necessary tools like Anaconda then I'm gonna set up our environment using condom and collect our data set which means download the images from Google and clean the data set then we're gonna annotate these images using the roller format and set up YOLO V8 using Ultra related plus and we're gonna train our model using two different way I'm going to show you then we're gonna evaluate the model that we created and see how good it is and make prediction detection on videos and images to test our model and the last thing that we're going to do is preparing free development on Hagen phase by creating the logic needed to deploy it on hacking face space this tips can be applied on only object detection project you can work on thank you for joining me on the journey and let's get started before we start writing any code we will need to set up our environment first and we will need one tool for that it's called Anaconda you have to go to anaconda.com and click on this download button and based on your operating system it will download the correct version for you after it's done it will take some times you can just go through installation I already installed mine it's very simple after you are done with the installation you can go to start menu and type an account and click on the Navigator it will open a couple of terminals don't worry about it then it will initialize the loading screen then it will pop up the Navigator tools right now we will see after the Navigator opened a couple of tools bugs are most important one is Jupiter notebook and visual studio code of course after opening this Avenue didn't find one of this installed already and you have this launch button existing you will find this install button in state all you have to do is just click it and Anaconda will install it for you automatically then you can launch it it's very simple and easy and also Anaconda comes with brain installed bison for you so you don't have to install it or download anything for bison at all now after installing cone down our PC we can start to create our own environment in any list that you want you can create a new folder for the environment name it whatever what you want I will call mine YOLO 50 e in v but make sure there is no spaces between modes because this can make issues Anaconda sometimes and we can copy this absolute pass for the folder to create it and go for an encounter prompt open it and write this line contact create B and the absolute pass and the version that you want for Python 3 point basically and hit enter and yes keep like give it allowed to proceed after it's done it will tell you how to activate the environment and deactivate the environment don't worry about this we will not touch this at all we'll create a new folder we can call it anything I will call mine the code and inside it we will start to create our own code but before that we have to condemn activate the environment that we created uh right now you can see it switched from base to the environment that we want and the cool thing when you install any light break that we want inside this environmental will not conflict with other library in our PC already because it's separated inside this environment only right now I need to install a library called symbol image download the versions that I want is 0.4 12 bam it's installed right now we can start coding just open your editor mine is Visual Studio code and create any folder file mean uh I will call mine images because I will use this to install or download basically the images that I want and from symbol image download that we just installed in board symbolt damage image download and we can give it a shorter name is ID for similar name and we will basically carry it uh Sid dot symbol image download okay basically invoke it to use it to download the images and right now what image that we want to install mine I want to install Construction [Music] or curse your can be whatever what you want and the cool thing you can add any amount of images that you want to install it will be installed for you in a separated folder and we can iterate on the keywords in the keywords we need to use the response that we created to download whatever keyword that you want and the amount basically this will Loop over our list and install each image basically in the front for this separated folder and the amount that we need is 200. and with this we can start to run it by typing python the name of the file that we created after a while it will be completed but tracking around you can see there is a simple image folder inside it a folder that's called construction workers we can see one of these images already installed like here it got a gear that we need the jacket and um well our completed our downloaded for the images we have 200 images and we can use it to annotate it but before we proceed I want to tell you about two places that you can get more images like please a Google open images data set it's basically for free you don't have to be anything it's some of it is already annotated you can explore you'll find a lot of stuff actually in useful but I don't think like it have it all not just open images that's it it's very good also key girl have a very good and that's it if you already know about these two we can basically I will leave these two in the link in description and now we can proceed to create our newest tip and we have to install another Library if an annotation and this one uh actually called a label image by might install label and the ice capital image after it's installed we can run it just typing label image and it will open for us after it's installation we can run it by typing its name label image and it's opened this is basically a very simple tool actually there is nothing so difficult about it but before we start using it we will need to organize our own folder structure for the structure of the project that we will need it's very simple all what we need is basically to go to the code folder that we created okay in your new folder called it data and inside it we will need two new folders images and labels images and labels and actually inside these two we will need the new to folder called the Train the train is for that trim data set only for images we will need another folder called validation or call it just file and here in labels we will need just a tree you will understand the why we're doing this in a in a minute with me then we can take from our symbol images construction worker um like you can see there is some images that's not clean basically like this is not construction worker image you have to clean this images and select like a hundred of it or 50 images however much that you can basically you want but I would recommend it's like not listening 40 images basically and clean the data take your time and clean it in Kobe what you need inside the train in images folder that we just created right now I selected the image that I want to clean basically want to work on and I will take it to the data images train folder and bust it right here M and we have our images right now our image is ready to be annotated all what we need to basically to go to our terminal right label image again and it will open for us and select the directory of the images mine is already I have been selected before so I just can select the folder and the outward where we want it to go in our case we want it inside the data labels folder that we created inside the train folder and we just select where it want to go and before we start please make sure that you are selecting your own any other format it made I made this mistake before after I am done with like 50 images I realize it's not yellow anyway right now I will show you how to create The annotation description below you click this or the second box go and wear what you want to label basically the bar that you want to object detect here we create this box and we will leave it call it head it's very simple and we want to also the jacket to be detected so we create a new label called a jacket [Music] okay right now we will have to do to all this uh basically hat and jackets and after we are done with any images basically all I have to do is click save and continue to the next one I am done with annotating the images finally inside data images train you will find the image that we wanted to annotate basically and for each image name here building worker three basically inside labels train you'll find the same name but for a file called txt This is basically that where is the labels that we wanted on the images basically for zero is had and one is a jacket this is basically where is this object exactly for uh inside the images this you'll know how to understand where is objecting images and from here we want just the classes thickest we will put it outside here in code uh no I will put it in data and for the classes we have just had and jacket that's what we created as labels all right right now we're gonna start coding and installing what we need to train our own model the first thing that I need to talk to you about is this Library it's called Ultra latex plus it's basically Euro but for deployment on Marketplace and I feel like that you've created a model and you wanted to share it the best list that you can bought it on right now is hug and face it's a very famous platform for uploading and we're going to use ultrolytics plus to do that and all I have to do if you remember we just have to go to an our own Anaconda brand and install basically web install Ultra analytics plus and little do it work right now after it's installed completely on our environment we need to check on Torch right by phone in the Anaconda prompt it will open recording please the board torch and torch that underscore under underscore underscore version underscore underscore right now as you see it's CPU the CPU we can use access CPU version but it is very slow and it will take a lot of time what we need to install actually is that what you call it the GPU version we can go to buy torch.com and click on get started we will give you the selected option here you can of course you want to select it a stable version and the operating system that you have mac Linux and windows and we need to install this pipe and the language is of course Python and decoder is the newest one would give you this Commander prompt after install we will add a dash dash upgrade [Music] I will leave this command [Music] in the description it will look like this it will take some times to install and after after installing it will replace the CPU version automatically you don't have to worry about it right now we will completely install the Tor GPU version on our environment right okay we right now again we will check on it the same way we did the last time or what doors doors that underscore version underscore and here if you can see it correctly here right now it's with code basically there is no CPU version existing on our environment and that's what we want because it must mean the CPU a a torch version is extremely slow you don't want to use it now we can start to creating the code that we will need for our basically Model A Very succinct we need is yaml file we can create in the coding folder to create another config yaml file and here we will give it a few things I will explain it the first one is best where are our root directory for the data set okay and where is a train uh basically images it's inside images go to train and for validation it's inside the images you know well okay how many classes do we have in our case we only have two The Head and the jacket and what are the names of these classes the first one if you remember in the class Turkish that we saved here first one is AD second one is the jacket we will make it in a Sim order you have to remember that because if you reverse the order the training will be flipped and right now we almost ready all what we need is just where are the base root the base route is basically the data folder that we created and give it the absolute pass and we copy it and put it here right now our remote file is ready [Music] right now we can start to create our own model code finally we can do it in two ways the first one is bison code locate file called Model trainer Pi inside it we're gonna board cholo from Ultra Analytics and we're gonna select which model that we want for sake of this tutorial we're gonna stick with a symbol version model we will have HV 8 in dot ammo I will leave the link for the other module basically the in it and basically the smallest one there is S and M and L and X there is basically the more the larger the model is the more accurate and it will better it will be but it will take more time to train it basically and for right now we need to basically to talk about the results we're gonna use this model that we selected to train and we're gonna give it a couple of stuff first thing is data and what is the data is basically the config file that we created the channel and the next thing is ebooks is the amount of time that we want to our model to lock to the images 100 it will take more time the more you add but basically the thing is this in 100 so it will faster in terms of trade but it will be less accurate the image size [Music] standard size and the workers is one and Lasting is batch I'm gonna set it for three batch is the collection basically think of it a bunch of images in one image and the model look at it we can put three or four or eight but the more that you bought the more consume them that you will need and this is how you created in basically bison you can run it and basically it will start to trigger mode but there is similar other way we can use we can in any terminal inside our environment we write YOLO task but the mode is the mode of the Stream and the amount of ebooks that we have is 100 and the data it's the same file that config dot BML and the model that we want to use we will use the YOLO V8 n dot instead of piano we'll use something called BT and image size is the same hot cards one and batch is three with just one line we can train our model I'm gonna press enter into 33. we started downloading the model that we selected it's very small mobile actually it's just six megabyte right now it started to train this will take some time uh based on your GPU and after it's done I will come back and we're gonna see the result of the training itself okay the training has been done right now uh it looked to 50 images and the two characters time mostly because it's 100 ebook right now we can go to the code folder that we created will find a new phone that called runs inside the detect and the only training that we did uh first thing that we want to look at is the result PNG if our training loss is not going down like this you did something wrong it might be that the image is not enough the amount of ebook is too low or something like that you have to make sure that the loss for the training box is going down and the Precision Matrix is going up because this also if going down that's mean there is something wrong but it doesn't mean it's able to detect the objects inside our images is a validation I didn't do validation uh we will live in the GitHub basically what I did for validation but it took its own validation anyway you have to check that the loss is going down and precision going up to make sure that the basically the training is good where our model it's inside the wage there is two models one is called Lost and the other one called past the best one that's what we will use the last one we usually don't use we can take a look at some of the images and see that it's detected zero is ahead one is a jacket right and right nailed it like this is what we not want exactly and this is perfect for us before we start thinking about our model and hug and face or any bleach we have to test it first we can do this by two-way and the first thing is using Code Python and of course a command that already made by YOLO first thing we're gonna do is the code because it's the easiest one believe it or not predict from Ultra board yellow and the model this time we can use our model that we created remember where did you bought it or the result of it is basically inside runs attacked green and wait and we're gonna use the best version and the second thing that we need to talk about when we creating this code and we going to use the model to predict a video interesting I have a couple of videos here I'm gonna leave it in the description where you can get it and we want to save the result of course by save and we need to also show it that's optional actually you don't need to show and confident level we're gonna do 70 percent confident level basically how much the model is sure about what he's seeing and this set save and run take some times okay it's done predicting and right now we can see where our results is our side run detect read deck and we're gonna see this video it's already working as intended it can detect jacket and head that is perfect that's what we need to know but sometimes you get like not sure if this is a jacket or not I understand why I'm I'm going to also mention how we're gonna improve this work by um by making the model see more images basically and using in a better version of the amount of Rolo basically the L or the M or even the X and turned or more times like for instead of 100 ebook like it took 100 or something that will make it better all right right now we're gonna try to predict an image and see if it can see there's jackets and the Hat by using an image from the validation but there is one option for the images actually we can save the bounding box of it in just one option save the XT and set it to True shave and run let's see the results outside predict C and you can see here predicted here this is the head and this this detected this jacket and the head and the labels that deducted a the one is a jacket just saw one jacket in the image and two hats that's perfectly working as you intended okay let's try the same thing but with command this command is very simple don't worry about how long it is it just basically YOLO attack detect the model spray Tech the model where is the best of the model that we created basically show is Through The Confident level is 17 you can change it and the source basically wears the pass of the thing that you want to detect an image or a video save is true where this is Project basically mean where do you want to outboard be safe that's it run and see the result okay doing the same thing exactly so there is two way that you can run a detection on a video or an image as much as you want you can use code or command all right right now we're going to work on the Hagen space part I guess business platform that's a free to use it's over a lot of stuff like deficits and rebuilt mobile is very famous if you don't have an account you're gonna need one to create a space inside it so I will leave the disk and I will leave the link in description for hacking space so you can create an account right now we're going to install a few libraries that we need to continue working on the Hogan space preparation tabular model we're gonna use web request basically to build our requirement the text and grid uh interface for machine learning model and we're gonna install it in our environment remember that all right right now everything I needed installed and we can go to Harkins space after you're done with the creation of the account I want you to create space you can come to this page and click on new and click space and select the name what you want mine I will call it Journey V8 Shifty and decorative line says we're gonna collect CC and for this we will select the grid view schedule is what we're going to use it's interface with we are going to use to create our app basically for hugging space or create a space and tell us what to do uh first thing that we need is to clone a space that we created let's go to our code let's open our editor and ask it to basically a clone this folder right right now it's cloned a jump inside it you look safety where it is a city all right we can inside it to create a new file we're gonna call it app.buy and inside app.buy we're gonna create a couple of stuff that will run our code as we wanted in hacking space if there is the thing that we going to do is import libraries that we use we need grid View and torsion Ultra electrics plus not are just alternate extablas because it will render the results and show it to our basic users second thing we're going to download a couple of images for our model basically if you're detecting whatever you get any images links and put it here and give it a name and torch will handle the double loading of these images from the web and right now we gonna talk about the most important part is the detection function this function you can call it whatever what you want it doesn't matter but you have to message this couple of parameters the first thing is the image that you want to detect and the image size this is important because the smaller the image the harder it's for the model to detect the objects and confident you already know what is the confidence threshold I explained before and this I owe you is basically is the grids of Euro that can detect our objects as the best of the model will be in the basically the folder that we created what the name of it is the best we're going to use the best Wiki that that we already created and the results of this model will be the prediction from the model and we message the parameter that we already gave it to the function uh right now we're going to use something called the boxes is basically is the what it say is a box is around the object and you will see this when we upload it and we're gonna render the result of predictation that we have from the model and the image and the results is basically is the very thing in the array and return it this is the hardest part actually about with this coming stuff is very simple next thing is the inbox what basically a grid you need is an inputs output and of course the function and title and example we give it the function we give it now the inputs it's basically the sliders for our or basically inputs for our function like where you can put the image and select the size and the confidence level and all other inputs basically is the is a lighter and you created here how about where we're gonna show you the image it's basically the base of it and the output image it's going to be named a title of our project I'm gonna call mine go to one one custom object detection and some examples the example is is basically we giving the function up here and one of the images that we downloaded and the parameter okay Siri symbol and last thing that we're gonna create is the radio interface we message the function that we created JM Butch that we made and where we want the output go and the title of our project and of course an example and the last thing that do we want to catch the example that we created you definitely won't do that so you don't have to basically take time to predict a model every time you definitely want to catch the example so the detection will be fast for it so right now we're going to create our coin tickets required tickets is what we basically telling the space what to download from the internet to make our code work just this line I will leave all this stuff in the description so you can basically copy and paste display request we already installed the requirement ticket is over here already created yes the gradual version that you installed the analytics installed and you can just remove this uh version You Can Let it Loose basically again space wheel or hug and face will handle which version we use of bytours and the last thing that we will need is of course the model that we created since I dream wage and Kobe go back and bolt it in here right now our model and file are ready and let's see what it tell us of course git add instead of add the buy we will basically add everything and commit our basically a file I'm gonna get add if you don't get I don't have Git You have to install it and we can copy the list there is a commit and finally get push write my space has completed right now that we'll see the cache is done and building is done okay as you can see this is how it looks this is the input that we created this is the output images is our example let's select one for example this one and it's already detecting correctly this is exact this is a hat but it doesn't detect the jacket but I can see there's a jacket maybe if I make this image a little bigger submit it will take time because this is for free it doesn't detect it actually we can play with like that so it can get a better result maybe with this image for example all the stuff will be on Good Times you don't have to worry about the resources okay you can play with the sliders mix confident level a little bit louder I always recently a little bit high and see the results but that's it that's basically how you can create a model and detect your own own database we learn how to collect data set and the annotate and how to train our model in different way and use it and see the details by yourself of the results and how to create organ space and output or model on it and make it work hopefully you learned something from the stuff all the code and all the resources you will find it in GitHub I will leave it Link in description thank you for watching
Info
Channel: Codewello
Views: 8,380
Rating: undefined out of 5
Keywords:
Id: h53XYgKzYYE
Channel Id: undefined
Length: 38min 37sec (2317 seconds)
Published: Tue Oct 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.