custom object detection using python and opencv | object detection using python | keras | tensorflow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] hello guys back to my channel and in this video I am going to show you how to create a custom object detection using Python and opencv so let's get started first open the Chrome and search for teach machine go to this website and then we have to train our data so click on get started wait for a few seconds [Music] yeah now from here we have to select image project click here and then standard image model now here we have in build two classes and now we have to take pictures of our custom objects and train these models so let us begin first of all let me connect my webcam okay so now I have connected my webcam with it and then after connecting your webcam you have to just click on this webcam option and then you have to select your webcam just I have to go and then here yeah now your webcam is you can see the picture from your webcam okay and now you have to locate your that custom object bring your webcam to that custom object yeah and now click on hold to record these will record these uh this will take the image of that object okay so let's do that because I will place these all right people hold to record yeah now we have uh this class we uh we are ready with these objects so let's close this one yeah we have closed this and here we have to change this class 1 as our bottle b o t t l e yeah it's done now here is class 2 and we have to add another object here so let us click on the webcam and now yes change this to my webcam and now I am having my mobile [Music] [Music] [Music] four models we have already trained and now after you can add as many classes as you want okay but uh now I am using these four classes and then after you have done these adding these classes you have to go to the next step which is training now click on this training model this will take a little bit of time so till then take a coffee break and subscribe my channel if you haven't let's wait for it okay yeah now it started training my models you can see yeah yeah and now we have completed our training these models let us reach our webcam again and now you can see that bring it down a little bit yeah and now you can see that this is detecting these bottles 100 percent as bottle okay uh okay yeah now it is detecting this at 100 percent this is a bottle okay and uh 9900 percent this is a mobile you can flip this also you can take it yeah you can see now it is uh saying 70 that is the mobile to focus yeah seventy percent chance uh this is a mobile and now if I show my Raspberry Pi here this is the Raspberry Pi you can see there's most of the percentage that is 80 to 90 percent uh it's showing that this is the Raspberry Pi okay so this is working fine and if I move it to my switchboard here also you can see that it's saying that it's a switchboard so our model is working and now we have to export our model so let's do that uh foreign model and from here we have to click transfloor turns flow and then we have to go save Keras okay from Keras we have to click opencv because we are using our camera to detect the objects so we have to click on this open CV Keras and then turns flow not here you have checked all these points and then click on download my models so downloading these models with uh take a little bit of time you have to wait for that it is converting this model and as it is written converting your model in Cloud this may take a few minutes till then uh leave it for installation and let's make a new project in our PI charm so here is our pie charm go to file new project give it a name as custom object recognition like that this window only okay so here we are having our new project in this pie charm and now we have to open this terminal and uh have to install some of the libraries so first we have to install these CV2 okay so pip we have to write pip install CV opencv and python this will install opencv in your computer if it is not installed but here in my case I have already installed uh that that's why it is showing that requirement is already satisfied and next I have to install these the Keras okay for this I will make a Google search here you install Keras for this we have to write this command pip install Keras we will copy this and we'll paste this to our terminal let's just paste this so in my case these also this is also installed in my environment so that's why it is showing requirement already satisfied but while installing keros Keras you will uh these two will take a little bit of time so you must hold patient be patients and now we can see this converted Keras it is downloaded and we have to open these now and then we have to extract this file extract two now we have to go to our project file I have to search a custom okay where is our custom object detection project uh I think here it is let us make a new file new folder okay and let's locate this file foreign yeah we have to copy these files from here and we have to copy this and paste it our in our pycharm location so paste this objects yeah and you can see that here is our files level.txt in this we have written this both mobile switchboard and Raspberry Pi and the next step is to we have to copy this code which is provided by this Tech Machine we have to copy this and we have to paste this after pasting these we will have to root check this out and we have to check our webcam and then click on run wait for a seconds this might take a Time we have to wait for it and yeah so now our file has run and here is our webcam footage and here on this terminal you can see what this is showing so let me put this towards my bottle yeah now it can you can see here that it is recognizing my bottle okay uh here it is you can see uh see here this is detecting this okay and let me try something like yeah here is the Raspberry Pi you can see and here also it is the mobile which is detecting this brings to the switchboard it is also detecting as a Swiss wood but here is a problem that if we uh if we are showing some objects which is uh not trained in the model then also it is uh showing something like bottle switchboard like these wall is not we have not trained these wall but then also the and so make some make these changes uh makes these work perfectly and confidently we have to make some changes in our code so let's so let's do that first of all stop this one and go down and find here probabilities okay you can find these probabilities on line number 30 and then under these we will just print these probabilities to see what is inside it just print probabilities probabilities okay after printing this now we can see a numpy arrays that is created by this model and so these let's run this model again this will also take some time let's wait for it yeah now our programs is started and you can see this first one uh this first one is for our level zero which is uh this bottle and this is showing this confidence level of our fast model that is the bottle this confidence level of the bottle the second is for our number one that is mobile these showings this confidence level of our mobile and this third one for the Swiss board and the fourth for the Raspberry Pi and as you can see if I go down over here if I move my camera move my camera towards this bottle you can see that these becomes the highest the first one which is for the bottle these is becoming the highest one okay and this is the lowest that is mobile confidence is lowest lower than these one okay and so these bottles confidence is higher that is why it is predicting this model as bottle okay so for that what we need to do we have to convert these array we have to convert these numpy array to our normal least array for that we have to do is this and we will print least we will convert this to a list okay we will convert this numpy array to our list now this is done and now let's see what's happens now we have to again wait for a few seconds to run this program let's wait yeah now our program has started and let's see what it tells so this is the Raspberry Pi and while showing this Raspberry Pi you can see that the last one last one have these greatest percentage okay as you can see this is having the 0.9 percent of confidence okay and whereas the first one that is for bottle it is having a very less confidence this is also less this is also less and the highest value is for Raspberry Pi because we have shown Raspberry Pi in our camera so these is the showing this is showing that the confidence of Raspberry Pi is more and less let us taste with other okay let's put this camera in front of mobile okay and now you can see that let's check which one is our mobile so our mobile is number one okay we are having number one as mobile and it is also detecting mobile so you can see that these part that is the mobile part is having the highest uh percentage okay so that's why it is detecting it as mobile here you can see 0.9 to 0.8 okay so now by these we can configure it our confidence level by doing this so let us what we are going to do is we will create a loop over here for finding the confidence of all the classes that we have created that is the confidence to check the confidence of both tell then mobile then switchboard and then rushberry pi for that we have to create a loop over here before a loop we will take a variable and store this values okay let's say from there we will copy this one will store these as then we are going to create a for Loop where for probabilities probably these probability sorry in this what we have copied we have to paste it over here and then give it a like slash then we have to write that if our no we can also write this as confidence c o and F this means this is the confidence and now we will write if confidence is greater than 0 point nine nine nine nine then only it will show uh then only it will predict our object otherwise it will not okay so then we have to copy this one and paste it like this okay click on paste what is coming sorry now this we have to copy this screen statement to this yeah I think now it's don't have any problems let's refactor this okay so the final step is we have to display the levels on our CV2 screen for that we have to uh take a variable fast so I have to make a small change over here by writing this so we have to change this image okay CV2 dot image so and we have to make this as let's make this as IMG and these also IMG make it and here we have to change this also as IMG so these are the small changes which we have to make and then we have to cut this and we have to paste this one over here paste this one then we have to also make these as IMG okay so let's run this code again and see what the error is coming okay so now we can see that it's writing this bottle but the text is not clear still now also we can see the switchboard this mobile everything is showing but the text is not clear that to clear this we will uh just stop this one and we will make it one okay and I think this is the Y position so let's make this Y is 50 and this can be made to zero 0.0 let's make it five okay and the color I would like to give is all sold something different let's run this code again okay so now our program is started and here we can see that this is detecting this as bottle as you can see clearly it is written this bottle okay and now let's here it is here it is written Raspberry Pi and here our mobile so here is the mobile also in case of Swiss board let it make yeah also you can see that this is written the Swiss board okay here you can see this is written switchboard here is the Raspberry Pi the bottle here's the bottle this is the mobile so this is uh how this works this is a real time as you can see there is no lagging in it and this is our project that how to make a custom objects detector you can uh by this program you can add any of any house appliances or anything you can train this model very easily and then you can detect that by your computer uh using python so that's today meet you at the next video still then like share and comment down below if you also if you face any kinds of error in making this program then comment it down and let me know thank you
Info
Channel: Art of creativity
Views: 1,695
Rating: undefined out of 5
Keywords: Machine Learning, Objectdetection, Python, OpenCV, raspberryPi
Id: mS6EXW_YkwQ
Channel Id: undefined
Length: 23min 38sec (1418 seconds)
Published: Tue Oct 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.