Official YOLO v7 Object Detection COMPLETE Tutorial for Google Colab

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to my channel in our last video we did yolo v7 object detection on local machine in today's video we will run pre-trained yellow v7 object detection models on google collab the code for all of our videos is available for our patreon supporters the link is in the description let's get started i have opened this new notebook on google collab called yolo v7 first let's enable gpu by going to runtime and then click on change runtime settings select gpu as hardware accelerator and click on save now click on connect and wait for it to get ready once that is done now we need to connect our google drive with this session let's do that from google dot co lab import drive and then drive dot mount slash content slash g drive hit shift enter to execute this cell it will ask your permission to link the google drive click on connect to google drive and it will mount the google drive after authentication now we need to move to the google drive we can easily do that by command percentage cd slash content slash g drive slash my drive hit shift enter once again and now we are in our google drive we can verify that by printing the current path with command exclamation mark pwd there we have it now let's create directories in the google drive and clone yolo v7 repository let's import os if not os dot path dot is dir let's say the coding bug then os dot make dirs the coding bug if we execute this cell it will create a directory called the coding bug in our google drive we can verify it by clicking here and then going to g drive my drive and here it is i have desktop version of google drive installed on my machine and any changes that we will be making in google collab notebook would also be reflecting here now let's move to this newly created directory percentage cd the coding bug and then exclamation mark git clone then we go to the official yolo v7 repository and copy this link paste it here and execute this cell it will clone the repository in our directory that we just created now we need to download pre-trained yellow v7 model that we want to run for object detection let's move to yolo v7 directory by command percentage cd yellow v7 and then in official yellow v7 repository scroll down and copy the link of any model that you want to run go back to collab then execute exclamation mark w get and paste that link if we refresh our google drive folder we can see that the model file is downloaded successfully now we are ready to run object detection on images and videos but before that we want to do some modifications in the code i will go to the yolo v7 directory in google drive and make changes in couple of files let's go to utils and open data sets dot pi in your favorite text editor then scroll down to this line that prints info after each frame it is line 181 in my case and we are just gonna comment it out save the file by the way if you do not have google drive installed on your computer you can also download this file directly from collab make edits and then upload the edited file okay the second file that we are going to modify is detect dot pi the first modification is that we want to fix random seed by command random dot seed and let's fix it to 1 this will stop generating random colors for the classes on each run for example if you will run object detection code multiple times same color would be assigned to person class instead of new color assignment on each run next thing is that we want to define fps that will be shown on the videos let's create a variable called start time before this for loop and set it to 0 then scroll down and before view image let's type if data set dot mode not equals to images current time equals time dot time and fps equals 1 over current time minus start time then set start time to run time now the fps is calculated let's show it on the image cv2 dot put text on im0 which is the same image that is saved and fps then string of integer of fps set the x and y axis offset font would be cb2 dot font hershey plane with thickness of two and in green color and size two this will show the fps only if video stream is given as input and not on images the final thing that we need to change is that we will copy this line from here and comment it this shows the information where the output is stored in case of images but we also want to show it in the case of videos so we'll paste here after the loop and in this if statement and instead of image let's type output here and one more thing we want to change the line thickness of bounding boxes three is too big for me so i will change it to one that's it save this file and then i will copy 2.jpg and street2.mp4 in yolo v7 directory as my google drive is in sync the changes would automatically be reflected in google collab let's go back to google collab and run command exclamation mark python detect dot pi minus minus weights yellow v7 dot pt it is the file that we downloaded minus minus conf 0.5 this is the threshold for bounding box confidence then minus minus img dash size which is 640 for this particular model as mentioned in the repository and then minus minus source 2.jpg it is running on tesla t4 gpu and the output is stored at this path if we refresh the folder in google drive we can see it is there and we can also open it from the google drive desktop let's run object detection on video now it is exactly same command only difference is that we need to replace source with street two dot mp4 the output is stored in runs folder and here we can see it and it's giving us 40 fps on average now if you want to run any other model just copy the link of that and paste here in wget command it's going to download that file replace the file name for minus minus weights argument and run the detection again and it will produce the results similarly change the weights file in the video command as well by the way you can also add minus minus no dash trace argument here to avoid tracing of model every time let's run object detection on videos using yolo v7x and the results are again stored in runs slash detect folders here we can verify them by opening the image and the video so it gives us 30 fps on average and detections for this bench these are now consistent with that i think i'm done if you have learned something of value today subscribe to the channel and turn on notifications to see future tutorials like this one consider a support on patreon to help the channel out i will see you next time [Music]
Info
Channel: TheCodingBug
Views: 36,651
Rating: undefined out of 5
Keywords: yolo v7, yolov7, yolo, yolo object detection, object detection python, object detection, YOLOv7, Official YOLOv7, Object Detection, train yolo in cloud, object detection classifier, deep learning, yolov5, yolov7 tutorial, install yolov7, train yolov7, yolo v7 tutorial, yolo v7 object detection, yolov7 python, yolo v7 python, yolov7 object detection, yolo7, yolo 7, yolo v7 official, yolov7 colab, yolo v7 colab, yolo v7 cloud
Id: _CkXDjmT8dc
Channel Id: undefined
Length: 8min 53sec (533 seconds)
Published: Tue Aug 02 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.