Real Time Football Player and Ball Detection and Tracking using YOLOv8 Live :Object Tracking YOLOv8

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys so in this video tutorial we will see how we can use yellow V8 for football player and ball detection so this is an end-to-end tutorial you will start with first we will create our own data set so I will go to roboflow and create an account over there then I will gather the data set from different YouTube videos then I will train my Adobe 8 model and then test it or model on different videos plus we will do a real-time testing on the webcam as well and see uh what results do we get in real time so let's get started so let me go to Robo floor okay so just click on the first link and if you haven't created an account you just need to sign up so I have already have an account so I can sign up but uh to tell you how you can create your account I will go to sign up option and just create an account over here so it might take few seconds so sign in Google so I'm just creating account I don't have an account on this email ID over here previously okay so just like so it might take a few seconds for it to complete the process okay login or create an account so I accept the terms of service and privacy policy continue so here I will click on Academia workspace name as mine and I will Skip and I'm so I'm a recommended community so public so all my data sets will be public if I use this or if you want to make your data set private then you have to get get a subscription package okay so I don't need a guided tour so I will click on create new project okay so I will doing object detection of player and football uh so I am detecting football [Music] layer so these are two things which I am detecting football and player detection okay and tracking so this will create a public project over here so so if you want to if you don't have any data set for our project so let me show you how you can create your own data set so I will have just go to the YouTube and just to have it from here let me copy link address and just give it so I will just paste it over here and just click on enter so it will now process the video complete video frame by frame let me show you so 60 frames okay so the video is around two minutes seven seconds so it's around 128 seconds the video operation is 127 seconds and from each seconds we will get a one frame so okay so we have chosen the frame rate so it might take some time to process uh all these all this video so in the meanwhile it process this video let me go to let me look some for another video let me know so for Portugal name video okay Okay so let us just copy this link in the next phase we will uh we will annotate this video as well so the first way we will just upload this video and then I will upload the second video as well then I will annotate both the videos one by one okay so it might take a few seconds more so let's wait and see so in the output we will getting 128 images as you can see over here so let me get back as it uh it's uploading completes then we will discuss further all right guys so we were able to extract 120 frames from the video and you can see that they are not educated yet we will annotate our data set they are all not annotated from you can see from here so let me upload uh another video from here but let me first save and continue this I'll just click on Save and continue so now these images will be uploaded into my data set so it might take some time after these images get uploaded we will take another video and upload uh extract frames from that video and then we will upload those images as well so it's around it's it will be three seconds only so very soon it will be uploaded over here so let's see three seconds remaining appearing so let's see how it goes okay so it's uploaded and okay so there the files are uploaded and we can see that so basically I am the only one working on this project so I will assign the job of these images annotation to myself so I will just click on assign images so after this now I will annotate every single image one by one from here but before we start annotating let us upload some other video so as well then we will do The annotation of all images once so just copy link address and just paste this link address over here and click on enter so it might take some time so let's see downloading this way while we process we process our video so just choosing the frame rate a bit higher so just trying to explain you so you can set the frame rate as one frame per second which we originally did in the first video so that let's click on Save and continue I will also take other videos as well from YouTube and annotate them once as well as well so just click on assign images so I will assign the job of this image images annotation to myself so now we can see that we have two jobs for Generation this is for the first video and this is for the second video let me go to watch the first video first and let's open this image first so let's click over here and let's do the annotation so in this way we will annotate all of the images which are in our data set you can see here so you can see that I am annotating every single image over here in this way I will annotate all the images in the data set we have and then annotate this as well and then rotate this image as well and then we will annotate this image as well so in this way we have annotated all the images these two are left let's annotate them as well okay so I have assigned a level football player to these images to all the labels over here now let's annotate this football first and the sign the label as football okay so no I think I missed it I just don't click on the save button okay so just click on Save enter what's the issue which are getting thank you foreign football so I will click on football so now it has created a class football now I will annotate this other players by click on football player and this one as well as well and this one as well and this one as well and in this I will annotate all the images in our data set one by one like you can see that I am doing over here I will not annotate the referee I will annotate all the other ones so and in this way we are annotating basically all the images and this layer as well now we'll go to another image uh and do the notation as well so first of all we will annotate the bar put ball over here and now we'll do The annotation of all the players okay so in this way we will annotate all the images in our data set so let me annotate all these images and get then get back to you so guys I have eliminated all the images in the data set for the football and for the football player and you can see that we have total around 800 a 1827 images two classes the one is football and other is football player so we have uh around 1200 images in that training set 675 images in the validation set and currently we are not taking any images uh for the testing set but I will rebalance it and make it around I will make it around Android and let's make around okay so in this way I will prepare my data set So currently we have 58 percent images in the training set after augmentation this person test will increase and 27 images in the validation set and 15 images in the testing set so let's click on continue so I am resizing my all my images to 6 cross 40 Cross 640 that is a for resizing all the images to 640 cross 640 is that basically our Euro V8 model is trained on 640 cross 640 images and if we are just printing none if there is uh an image on which no annotation is done so it will be skipped so basically as you can see filter none require all the images to contain annotations now so if our data set size is not enough so we need to augment the data set so that we can increase the word uh data set plus we can make our model a bit more aggressive against the bit more aggressive so our model gives more better results if you do augmentation so here I am generating augmented data for example this is an image it will create two more images from this image which is one will be minus 15 degree calculated and other will be plus 15 degree that rotated plus we are doing this we are just changing the contrast of the image so it will generate two images from this original image with different contrast like minus 25 to plus 25 it will randomly adjust the colors and then we are also adjusting the brightness so from this single image we will detonate two images one will be more bright and one will be dark okay so and just we'll click on continue now I will click on generate so as you can see that we are donating uh two images from a single image so that our data site will definitely increase now okay so we can train our model your videos in your roboflow as well but we will click on export because robof provides a no code station but I always like to do some code work so I will click on export and Export this model into our uh you know V8 colab file and then we will train our model and do the prediction on some output videos as well so just copy this command to the export a data set from roboclow into your Google collab notebook so I'm just copying this and just go over here so first we connect uh our Google drive with the Google app so that when we run training our weights are saved into the drive so if there is a sometime disconnect or runtime restarts so our weights will be saved into the Google Drive so just mounting our Google home app notebook with the Google Drive so I have already trained your model the models but I will overview all the steps that I follow to train in this model so from IPython or display import image because we if you want to display some input output image into our Google app notebook so we need this Library and then uh foreign by the name football you can see this folder over here this is a folder named footballs and just setting this folder as my current directory so for this project I will be using let me show you um okay so I will be using this GitHub wrapper for this project you can see over here so you can just click over here and just Mount uh clone copy this link from here and just so on this GitHub wrapper over here by just Ctrl V so basically in this folder I have already mounted my Google this oh I have already cloned this GitHub repo so it's downloading over here you can see that so I already downloaded this GitHub repo so you can say I've cloned the GitHub repo so you just need to run this cell and then you will set the see the what is your present working directory okay so now I will select my current directory as this GitHub repo which I have ground over here so just click on copy path and just paste this over here and just run this cell now we need to install all the requirements or dependencies to so that all the libraries gets installed like matplotlip numpy c bond so when we run out the training or the prediction we should not face this error that the following libraries is not installed so when you run this so it installs all the dependencies all the libraries so we don't face an issue uh we run this dependencies installer script so it might take few seconds to run so let's wait and see so the dependencies are being installed now okay like you can see that we are just installing a ginger to mark down Alternatives and so on so now we are just moving towards the required directory detect because we are performing detection so we'll go to other Alternatives YOLO V8 and click on detect and we will just move towards this required directory because we are performing detection now we basically uh we have created this data set into the our robot flow so we will just copy this from here and just paste this all from over here and just if you run this cell it will be downloaded over here like it has been downloaded over here you can see in this way you can simply run this cell and download this data set from Robo flow into the Google notebook then we basically have to implement deep sort tracking we need to download the Deep sort files because we are implementing object tracking using deep sort so I have placed a deep sort file into my Google Drive so I'm directly downloading those files from the Google drive into the Google app notebook so just run this cell so it will download the deepshot files from the Google drive into your Google collab notebook and by running the cell you can unzip those files so already as you can see that I have already downloaded these files so from the unzip I have already unzipped these files but I will click on all and unzip this files again because I have already done this script before making this video so already these files are downloaded and unzipped so now I will run training or the I will train the custom model of your V8 model on this uh football player and football data set so so we have five different models available in Yolo so if we choose the smallest model which is yellow V8 n so it will give us the it will be fast and it will take less training time but it will be less accurate while if we choose yellow V8 which is the best accurate model so you know v8x is the best accurate model but it takes more training time and it but it gives the more best results but the training time taken by euro v8x is uh more than other models at its processing time is quite higher than the other models as well so I've already trained this model on you can see that around 70 80 bucks so I will not be training this model again okay so I will just uh go through the files in the advanced detect train folder so when after you complete that training so we can review the files we have in the training folder so we can see that we have the F1 curve Precision curve we call Curves and we have also the training and validation Bank results as well so if you want to display the Precision curve we can also display we have the class football and player and plus we can also display the Precision recall curve and I have saved the model weights into the Google Drive so if we just in case we don't want to directly download the weights from the Google Drive we can also download the ways from the Google drive as well okay so in the next step I will if I will validate my custom model so we can see that we are getting a good mean average Precision with iou50 as 0.087 and 0.913 and we can mean average Precision when IOU varies from 15 to 95 is 0.63144 and 0.476 for the players so these results are very good okay so we will just download some demo videos to test how our model works okay so I have downloaded some demo videos from the Google Drive you can see that over here so let's run uh over this demo video and see what results do we get so it might take some time for the script to execute so we will wait and see uh our script execute and what results do we get in the end so now we are just performing predictions so let's wait and see what results do we get after doing the prediction on some Sample video I will test this model on live webcam as well and we will verify our results from there as well so it's 22 player 21 1. okay so it's detecting the players as well as the football you can see over here so I think the model was working fine like the players are being detected the football has also been detected you can see from here so it might take some time so as it completes I will be back and then we will see what the results we get so the prediction on the demo video has been done so just let's copy this from here and see what results do we get okay so just copy this path and just paste this path over here and just write videos to dash stream this is the uh output video name okay so let's see what results do we get let me show you basically where my results are saved go to my drive football eurovia deep sort tracking then I will go to your runs detect train 14 and this is the output video name so just we're going to copy path from here and just paste this path over here I have just done this manually but you can also do this by Ctrl B and just see what actual results do we get from the output so it might take some time so I can just directly download these results from my drive let me go towards there and just click on new tab and just go ahead Drive and then I will go to football and here I will go to Yellow V8 and then I will go to runs detect train 14 okay video two dash stream and just download this output video the file size is large so it might not be able to display our Google collab notebook so okay so we can see the results here as well you can see those okay okay so here the ball was detecting football so let us see so long from the other ahead the model is also able to detect the football as well but here the model is making that wrong prediction with the player and football okay here the model is also able to detect football so overall the model is working fine but uh in terms of player but and in case of football some detections of football gets missing but you can see that we are able to detect the player and assign a unique ID to each player and attract the player as well and we have our Trails as well you can see over here the trails as well so I see a mistake over here like basically every you can see that we have different players in this video so each player is being assigned a unique ID like 253 34 but we have a single football so we can have Trails but we don't need a unique ID uh with the football so I think we should remove it so what we need to make the change in the code let me let me show you so just open the project.pi file and just go over here and just write if label is equal to football okay and just create another thing and if label is equal to player okay and just press enter and just copy just [Music] make one change just set this as now and just copy this from here and just paste this from here and just remove this okay so label percentage so I think it will not work fine we will not have a unique ID with the football and just save this okay and just run the step again and see what results do we get now okay now just run this cell and see what results do we get I hope we will not be able not getting the ID with the football because we don't need it because there is a single football in the match although they are quite different players so they can have a unique ID but we don't need uh ID with the football let's see what the error we are getting the local variable labor record for assignment let's see what's there let me open the predict.pi file and I think I have made the mistake and it will be okay I'm recognizing right so here it will be object name and here it will be object name as well so now it will work fine and I hope you will not get any issue let's run but if there is an issue we will definitely fix it okay so just checking renaming this file as well so it might take some time and let's run this script as well again okay so we are now running this script again so I know it might take more time using layout okay the it has started so as this process complete the the predictions are done on each frame then I will back and we will see what output video we get all right guys so the predictions on the videos are done so I have just downloaded this output video so uh as it completes I will show you the results where the the ID assigning is being removed from the football is still there because we don't because there is a single football um in the match so we don't need IDs in different IDs in each frame rate we only need unique IDs with the football player so just open this and just see where okay so okay so I think it's working now and just okay so you can see over here uh we don't have a unique ID with the football we only have the trails that's fine although we have the IDS with the players and there is no ID unique ID with the football so that's where uh the unique ID with the football has been removed we only have the unique IDs with each of the players okay 271 270 to 73 that's perfectly fine now what we will do is we will test this model on live webcam as well I have a football I will just pick it up and I think it will detect myself as a player so let's test this model on the live webcam so to test the model on the live webcam I will download the weights file from here and let's see what results do we get over there as well so now you can see that we are testing our model on the live webcam so as I'm not up there so it's not detecting because I'm not just as a player so it's not detecting me as a player but you can see that the football is being detected by the webcam so our model works very fine over here the model is able to detect the football you can see over here and as I'm not being dressed as a player so the model is unable to detect me as a player file but the model is very successfully detecting that there is a football and the results are quite fine uh very good because I'm not standing or understating and I'm not dressed as a player so the model is unable to detect me as a player while with the case of football the results were very perfect and they are very fine supervisors so that's all from this video tutorial and see you all this next video tutorial but uh just to show you that I have written this script for to do predictions on the live webcam uh you can you can see over here uh I have um written from alternatex import YOLO model is equal to YOLO here I pass pass the weights file which I have downloaded uh from the collab file so these are the weights file of my model and here I'm just doing prediction so I'm setting source is equal to 0 show is equal to true so that I can see that the testing live and confidence value is set as 0.15 so this is all from this video tutorial see you all in the next video tutorial till then bye bye
Info
Channel: Muhammad Moin
Views: 13,244
Rating: undefined out of 5
Keywords: YOLOV8, objectdetection, objecttracking, yolo, objecttrack, DeepSORT, computervision, opencv, pytorch, machinelearning
Id: DsIW-DnaS7o
Channel Id: undefined
Length: 30min 59sec (1859 seconds)
Published: Mon Feb 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.