[MUSIC] Welcome everybody in today’s video. I’m going to be walking you through building your very own object Detection classifier using Tensorflow 2.0 I’ll be walking you through the process and code from start to finish showing you. The commands necessary, so that by the end of the video, you will have an object detector that will be able to detect classes of your choosing within images and videos in real time. This tutorial is meant for people with either a Windows or Linux machine. If you are new to the channel, please subscribe to the channel and smash that, like button down below. I promise it will bless your object detector with good luck and make it work even better. Well, not really, but please do it. Let’s get going, Alrighty, So first things. First we got to get the code, so you’re gonna head over to my repository. The Ai guy’s code and its Yolo v3 I’ll leave the link to the code down in the description below, so you can get access to it easily and a quick disclaimer before we get into the video. I forked this code from Hart Killa, who had an implementation for Tensorflow 1 and then I adapted his code for Tensorflow 2 and added some stuffs for custom trained weights, showing how to use custom trained weights. So yeah, so this is a Yolo version, Three object detection with Tensorflow 2.0 If you don’t know Yolo. V3 is one of the fastest object detection frameworks. It’s in real time pretty much. And if you want to learn more about that, you can go here and go to my Youtube video showing how to actually train a custom. Yolo Version 3 model as well as how to install Yolo and stuff like that and so, yeah, this is going to be how to build the object detection with Tensorflow 2.0 So let’s get into it first things first. We’re gonna want to go over and first click on this, so we can actually clone it, so we’ve copied it open up a command shell and just go get clone and well paste that in there. So once you get the code, you’re just gonna want to. CD into the repo. And I recommend doing code Dot to open up a vs. Code. If you have it or any other code editor just to look at the code, so we’re gonna go ahead and do that and that opens up vs. Code, and so we have a couple different scripts and a couple of different folders. So first the tech Dot Pi is what actually runs the detection and you can do detection with images or video. It works with both. And then you can also have your. Yolo version 3 which is the actual building of the model itself and then load weight so load weights. Is the big one. It will take your. Yolo v3 weights format and convert it to tensorflow model dot checkpoint files. So that’s really the big file, and that’s where we’re gonna start so we’ll just head back to our repo and follow the steps so first is to install the requirements. So you’re just going to go down your command Prompt and Pip install – our requirements. Dot TXT and this was gonna go ahead and download all of the dependencies that you need. I already have them all so you can see that it’s already satisfied, but that’ll go ahead, Pip. Install -. Our requirements will get you all the dependencies. You need to get yours. Tensorflow environment setup. So if you’re on Linux, you’re gonna go ahead and download. The pre trained weights were using the weights for the cocoa data set. If you don’t know the coca data set, it is a data set that is pre trained for over 80 classes of images so you can go ahead and Google Cocoa classes, data set classes and it’ll show you the list of 80 classes that are trained in the detector will work on straight out of the box. So that’s pretty sweet. We’re gonna take advantage of this, but it’s got loads and loads of classes and a variety of things like skateboard, different fruits, animals, people, cars like it goes on and on. So if you’re on Linux, you’re gonna run this command W get, but I’m on Windows, so you can actually just go ahead and click here, it’s gonna go ahead and get the Yolo v3 weights, so we’re gonna wait for that to download and then we’re going to move it into our weights folder, so it’s a large file, so I didn’t want to put it in folder itself, so I’ve just showed you guys how to download it, but you’re gonna put it in here, and if you’re using a custom, I’ll show you right now if you’re using a custom classifier, so if you check out my previous video here, how to train a custom object detector for Yolo and get the weights, you would put those weights into the weights folder and you would have to change a couple files like your cocoa name so that you know the classes you’re pointing at as well as the weights themselves, so the couple changes for you to allow you to do your custom trained weights, but so if you want something in specific, that’s not already in the cocoa, you go ahead and watch this video, generate the weights file and come back and now and stand up your tensorflow object detector, so it looks like our weights is downloaded, So we’re gonna open up our. Yolo v3 where we download cloned it to so, And I did it my C. Drive my repos, and this is the one we did, and you’re gonna go to the weights, file weights folder, and you’re just gonna drag in your uo V 3 dot weights into here. That’s perfect, so it’ll be in your downloads, so you can just open up and go to your downloads and then copy it in as well, so we’ve gone ahead and we’ve got our weights so now we can actually load the weights, so you’re gonna open up your command Prompt again and is a super simple command. This will generate the tensorflow checkpoint files for the detector. It’s just Python load weights, dot pie, and you’re just gonna go ahead and run. The command doesn’t take any parameters. It works just like that and then, so if you were to change it, you would go down here if you a custom detector. I mean, you would go down here to your weights. Yolo v3 dot weights and just change that to whatever your custom weights file is called, so it’s really easy to set it up for a custom detector as well, but out of the box we’re gonna use the. Yolo v3 cocoa pre-trained one. So that’s work. That’s work. You’ll see model has been saved successfully. And if you go back to your weights folder now before it only had. Yolo feet. So you don’t weights and now you can see that we have tensorflow model dot checkpoint files so that shows that our model has been successfully built and we now have the tensorflow model files needed to do our detector, so it’s that easy, and now we can head back to the repo and see that we can right away. Go into detection X, so detect up Pi is the script that does the detection X for us, and it takes in a four parameters it takes in images or video. You just have to say images if you’re doing images and video, if you’re doing a video, it takes in the IOU threshold, so this will be the threshold to be how close two objects are together. If you want to merge them into one, so let’s say you had multiple elephants in one picture by setting that to a different value is just 0.5 is what? I recommend. If you’re not trying to mess with that, but if you change it lower higher, you’ll see that it’ll impact whether it groups the elephant detections together or if it does just individual elephants. So that’s cool you can play around with that. The third parameter is the confidence threshold, so setting it to 0.5 means that for any of detections under fifty fifty percent confidence, it will not show the detection. So you can see that these ones are all high, but it’s a dog was forty. Three percent confident. It would not show that so you can alter this. One would meaning It has to be 100% confident and zero means that it would show all the deductions so you can play around that value as well and then finally, your last parameter is just the image file paths that where your images are from the root directory of this uo v3 so you can see that you can just put milk. You can put multiple images if you want and it’ll run multiple detection Z. So let’s try that out. I’m going to do Python detect Dot Pi and I will do images 0.5 0.5 and then there’s these two images that are pre downloaded inside for you guys. So its data images. Dog JPG and we’re just gonna go ahead and run this so right now it’s running it through the tensor flow model and it’s doing the detection using tensor flow. This is great for if you want to package this up in a docker container and deploy it to production with kubernetes. And I’m actually gonna working on a video right now to show that how you can package this tensor flow model up into the cloud and actually deploy it and hit endpoints that will run these detection for you. So all your images will save, and if you go your files and you go to yo v3 in the detection folder. So if you run multiple files, they’ll all save here, we open it up. Let me just drag it into the screen, so you can see it so you can see that. It successfully got truck, bicycle and dog all with extremely high accuracy. And if we go ahead and actually run that second image so. I said it came with two inches. It also came with office JPEG. So this time I’m gonna run the same command, but I’m actually going to do both images to show you that it indeed works with both office JPG. Run it and it’ll save all of these to the detections older for you, but like. I said I’m gonna have a video coming soon to show you guys how to actually get this working. In a docker file docker eyes this and be able to deploy it with kubernetes so you can see the detection czar lower. And if we had set the threshold to 0.6 for confidence, this would actually not be detected. So you can see how you can play around that, so we go back to the detection folder and we now have both. We have the same one we had before dog. And now we have detection 2 which shows an office space with chair, detected TV monitor persons. So you can see these are a couple. These are would be three of the classes within the cocoa pre-trained data set. But there is a bunch of more. There is 77 more. I guess there’s 80 classes so you can play around and look up that and put a bunch of images, so it’s really that simple, and now I’ll get into an example showing. You guys a video so we can do the exact same detect op Pi Command, But this time with a video file and it’ll load the video into our tensor flow model and run the detection. Zahn, so it’s going to be the exact same command Python detect Pi, But this time, we have the first parameter set to video then 0.5 and 0.5 for the thresholds. And then now we point to data video and I have made a video called Object. Dot MP4, and let’s run that so this should run the detection Z on our video and then save our video in the detections folder that we saw the two images get saved in. So hopefully this works. Well see it’s yet, so it’s doing the video right now. It’s fairly slow on the video when it’s doing the detection because I don’t have the strongest GPU or computer itself, but then you’ll see that when we run it back, it’ll actually be in real time. The detections it’ll be full speed, So hopefully this works. I’m gonna let this finish and then I’ll show you guys The detection. So the video, the video is done detecting it’s been saved successfully a couple warnings, but don’t worry about those and then saves to the same folder all of v3 detections and it saves US. Detection is done it before. So we’ll open that up and I’ll drag it in and Ill. Just rewind it for you guys. So if I rewind it. This is just me walking around its. Not my sock was a surfboard. This he’s the remote. The TV remote grabs the fork struggling on the fork a bit sees. Bowl can do plates, all types of cutlery and my back. This is my backpack, but it’s not like it can’t really detect the backpack because it’s upside down, and then it detects me as well. So yeah, you can see how it works. Well, with videos as well and it can still recognize those eighty classes. So I urge you to. Maybe that was shot with my mic. My phone, so just take a video and upload it. Do you detect all pie and see if it works so yeah, that works with the video. That’s the example and then. Ill, my to-do list right now is to finish full migration, so it is compatible with tear Tensorflow 2.0 but there’s a couple. Tf compat be ones that still default to the old functionality for certain like savers and assigning variables. So I’m still working through those. I’m going to update. So it’s fully migrated to TF 2.0 I’m also working on building the model training so that you don’t have to train in the Yolo v3 architecture. You can actually just train straight from this tensorflow architecture as well as my last, but not least tiny. Yolo configuration. Right now. You can’t load the weights for tiny Yolo, So I’m working on that as well, so make sure to check out. Keep checking this repo for updates, and I’ll make a new video detailing how to use tiny and stuff like that when it’s fully uploaded. So I hope you guys enjoyed this video on getting a object classifier up and running, built with Tensorflow 2.0 Please drop a like on the video and show some support. If you enjoyed this, it took me a little while to create and also subscribe to the channel and make sure you can come back and get notified when the new video with the final modifications gets uploaded. You won’t want to miss it, so thanks so much for listening guys and watching, see ya [Music]!