Real-time Object Detection on YoloV5 with Flask - Webcam/IP Camera

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone my name is jasmine tubal and today i am going to show you how to make the yolo v5 model with the real-time camera so many of the users were asking like how to do the real-time prediction or let's say i open my web camera or ip camera and how do i detect the real-time objects that in our surroundings so many of the users were asking that and i was also trying to implement that from a long way ago so today i'm going to show you how to do that so basically we will upgrade the previous repository only which was the euler v5 model like i will share the link in the below description also which was my previous video for video and images tracking with yolo v5 model with the front-end at the flask but today i will also implement a new feature which will be having a real-time camera detection so let's get started so yeah let's start it from there only so this is let's say open my document so this is our mainly objective on the aim to detect object in the real time with web camera through hulu v5 with flask at the front end so let's talk about the requirement first we will be having a python language for coding our code then we will having a flask flask user like web server or you can see a flask is a python package or you can say library which which makes you accessible for a server and then you know v5 is our model which predicts our things and the last data like you can say one of the most important requirements is your developing skills like i'm using linux and many of viewers were of windows user so you are saying that you are not able to implement the video you are not able to do the things so you should be having some debugging skills on your own so try to do that also because like we have i have linux there may be some dependencies issues or there may be some platform so you try to like go through the overflow stack overflow things and the like go over through the google everything is edible on the google so you can go over the resources let's click on the first link so basically it's a python language if you don't have python installed on your windows or linux you can install it over here how to minimize it yeah so yeah you can download it from the python over here and let's say you have downloaded the python you can click on the link and then you can download the package according to windows installation or linux installation and after that what was the second requirement second requirement is a yellow v4 model how to use the yellow v5 but the diff difficulty is that you can you have to do it in a command line also you don't have a ui interface to do the all the things so for creating a ui interface i am using flask you can use the technology let's say you are making for a mobile application you can use the flutter or android android sdk and whatever you should so basically back in have the code for drifting the model and in the front end there can be anything that whatever suits you so here i am using flask only you can use something else also it will work but you have to do lag code also so also like if you go over there github repository so this is the basically repository this is from where i got the code i haven't written all the code from my own the back-end code or the model code is different referred from here it's a ultra analytics alternative organization that hosted a yellow effect repository so it has all the code of how to do the prediction how to train the model and how to do the things what i have done i take the detect.pi file and then modify it according to our name so that i can integrate with the front end so this is one of the requirement also you can see it have like very big code you have to understand the things before you can run the things so what i have do i have also simplified the code and make it or yeah you can say uh in a one place also so you don't have to go to the different things like where is the document so if you click on the third link i will share the document also this one so this is one of the repository that i have created and it's referred we are of course sleep at the yolo v5 file your opportunity that was iphone before so i have taken only the important files and then for that is required for prediction and then also i did the flask framework of flask fronted code over here so what you have to do you have to clone the repository and then you have to do the prediction pretty simple right so let's see also there is one more one bug which i also want to fix that before going to the real time tracking so let's try to do all the things in this video so i hope you are going to uh you are excited for that so okay let's start it so yeah i'm also hoping that you know the github so basically github is a virtual control system which hosts your code online or you can manage your track your code and it's also public available so you can go to the link i will share the link in the description it's also in the document so you can go and copy the code so also make sure you have it installed on your terminal or command prompt open your command prompt if you have windows user or terminal if you are a mac or linux user check that this test has project if you get this you you know that the kit is installed on your system if not you can download it from the official repository also if if you don't have a github it's not a problem you can get the download zip file it will get all the code in a zip format and you can unzip it so i'm making i'm assuming that you have get installed copy this link open your terminal and first go to where you want to place your code like i want to place my code inside the extra repo which i have my repository i can do a git clone over here and then let's wait to complete it so you can see i have get the code you can you can go inside this repository by using cd command yeah i'm inside that like if you do the ls you can see all the code that here i was having it's in my repository now you can check this by opening your what to say file explorer and you get all the code inside your repository or inside your folder so now next work is to open your vs4 you can do the code or open like normally like how you do it so now you can see you got your code that was online now you have in your local system okay that's fine well and good enough so let's open a new terminal over here so yeah before starting uh i want to know some of the files that i want to let you know i have i have explained them in my previous video you can go over there but some new files that i want to explain here so as a requirement txt file so in this file what it does it makes the pip is basically a python installer it helps the python installer to let know what are the packages required for the system for this application so you can do the pip before that you can do like something like peep install and what we've installed that's requirement that it will install all these packages that are required for this application but before doing that i recommend you to create a virtual environment so what virtual environment does virtual employment environment create a python environment or i stand on or you can say isolated environment that does not affect your main python environment so it helps in like when you want to test new object or testing test new things you can do that with the help of that so for that you have virtual env installed you can do virtual env venv and if you don't have virtually any install you can go with google and type python virtual v virtual vnb install search for something like that and you will get the command how to download that like where was i yeah you can do the pip install virtually nv so okay first make sure you have pip install virtual png first do that it will check if you have pip installed or not if you have installed it will show like this and if you don't have it so it will touch you after that do the virtual env so what it does it creates a virtual environment for you for your environment like let me show you so if you do now source vnv then activate now you can see i have got a virtual environment over here so also check for the windows how to do that because there is something different so check how to do virtual env in windows you will get the link how to do that okay so this is all for now and now you can install the python repositories for now give me a minute you can do fifth install it will install all the files you can see that it's downloading all the file if some file is missing then it can download it and if it already present it just take it from the you can say from your local system so this is how the virtual environment takes the files from your local system and all things wait for this to complete so once it's completed you can see i got a message successfully installed markdown and all the packages that were required so yeah everything is now set up so one last thing which i want you to do that click install flask if it not done basically it will be i guess there but let's say if not let's download it flask so when flask is downloaded what you can do you can create a flash pattern so you will get the server like if you if you can get a message like running on the this this localhost area so you can see there's our application this is our front end which contact with our backend so like you have the option for opening the video cam then choosing a file and sending so basically this is the previous one where i can send the images and the videos but this is the new one where i can get a new camera so before doing that i have there is something missing in the new version of the torch which i want you to fix that before going towards video cam so let's say you choose a file and then let's say this is my image let's save this image and i send the image so also check your terminal like you can see there is something going on the thumbnail file storage is check my file whichever i send it and then it's do a normal this thing and then it's going over the yellow packet euro v5 you will get some error let's wait for that yeah you can see that we get error up sample object has no attribute we compute factor just copy this error go to the google and paste it you will get the some link let's open this github one and there he shows you how to fix it like where was that yeah for anyone looking for a solution modify your up sampling file e conda lip site package this is this this this according to the function above so really this line is giving you the error you have to comment this line and it's saying you to go over the light side packages dots and then modules so what you can do you have v and v install that's why i make you install the vnv go to the vnb then live sorry lib python site packages and then search for the torch over here so this is dodge and then go for the nm this is nn then go for the then go for the nm inside and then and in the modules so go inside the modules and then you will find the up sampling file this is wiki sampling file okay then search for this line up factor copy this line go over here find this line and this is the line that you have to comment so first make the bracket to the below line and then comment this line so this is how you have to do the things comment the above line and bracket to move the back downwards because it either way it will get you compilation error so this is what you have to do once then close this file and close the server here then do the flash run again uh open this link again let's try now smith uh sorry a smith one sent now also make sure to check the terminal because many of them you will be getting errors only here only so make sure you are getting some if you are getting errors go google the errors okay before like commenting you can google the error if you can find the answer then it's well good and if not then you can comment over there i will try to help so you can see once downloaded i get the download button over here let's click on the download so i get one jpg file okay downloaded let's open this download file yeah okay that's good i got a person accuracy so basically they are giving two boxes because it's a previously predicted image let me show you some other image i don't have a good image check this one that's okay i'm sending it again it's going over the phyton yolo model again i'm doing it showing it's doing it's getting the yellow v5 predictions using layers then let's click on download now once you get like this one post detect confirm success 200 is a success message then you can download the file if you get some error it will not be downloaded it will be downloaded in some other format that will be not a good like you can see now it's getting good i'm getting an accuracy 0.37 and saying it's a person so yeah that's good and now i will try to show you how to do it with a video card so yeah now let's do for the webcam the real one that's you all are waiting for so let's click on this video cam button so you can see it will get over the code over here here then detect.buy let's wait for the video cam to open you will get a video cam interface so that's it yeah you can see there's me and you can get a prediction like i'm a person it's also predicting from the previous scenery also like it's a person for him too so yeah it's pretty good so this is how you can do with the real-time tracking with the yellow v5 model so i hope you learned something also if you try to close this it will not close you have to do a command c over here ctrl c to force close it so this is some error that i am not able to fix it you can check that how to do that so yeah this is all for the working and let me show you how did i achieve this real-time tracking so like previously things that how the images and video work i have shown in the previous video but this video cam thing is a new so what i have done if you go over the detect dot not director by if you go over the app.pi i have created a new new new endpoint which is known as open cam so when i click on this video cam button it's send a get request to the backend that open cam this one request and what it does it run a process known as python three detect dot by source slash zero so it does uh it it uh like detect.pi is our official file that was created by rolo v5 euro v5 creators and i just called that dot pi from my flash server so this is how it is doing so it's calling a python three detect.0 so yeah this is all for now also something i wanted to show you before closing the video some errors that were in the previous video i wanted you to fix that so many of you are saying that these commands are not running like it's going over to the like this this line and the basically image you are not getting so also make sure you have python 3 in your environment like if you do python 3 test as version if you are not getting like this then you have to install python sometimes what happens it install as a pi dash dash version in windows so if you have pi test test version if you get the version by doing the pi dash dash then instead of writing python over here you have to do pi everywhere right here also so if you have pi installed i test if you get the version by doing the pi data version if you get the version by doing python 3 then it will be written as the python 3 only okay i hope you understand this next was for the windows user so basically this command subprocess dot run is basically for our linux user so if you wanted to run on a what to say in a you know in a windows then you have to do a shell equal to true everywhere like whenever there is a process return you have to do us what to true if you are windows user if you are linux user no need to do that if your mac user no need to do that but if you have windows users you have to write cell equal to true sell equal to true cell equal to true also if you have python 3 installed as of as a command environment variable then write python 3 over here if you have i installed as a python environment variable then you have to replace it with 5 i hope you understand this one so yeah this is all for now i hope you learned something new so this is all for now i can take a leave now so you can also connect me on the linkedin i will share the link so happy to connect with you all thank you
Info
Channel: Asmit Vimal
Views: 23,664
Rating: undefined out of 5
Keywords: #yolo, #yoloV5, #flask, #webcamera, #real-time, #python
Id: 0_KKyfUsmS8
Channel Id: undefined
Length: 17min 59sec (1079 seconds)
Published: Sat Jul 16 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.