Install Tensorflow Object Detection From Scratch in 5 Steps | Python Deep Learning

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] so what's happening guys my name is nicholas renate and in this video we're going to be taking a look at how we can easily install the tensorflow object detection api now this can be a little bit tricky if you're installing it for the first time you could get lost in sort of the wrong versions and sort of go down a rabbit hole it's really easy to do but we're going to clarify all of that today and run through this in five key steps let's take a quick look as to what we're going to be going through so now there's five key things that you need to install in order to work with the tensorflow object detection api so first up you need to install python so we're mainly going to be working with python and tensorflow then you need to make sure you've got the visual c plus plus build tool so this is what tensorflow relies on when being compiled if you're using an nvidia gpu you also need cuda and cud nn so these allow you to accelerate your deep learning and train a whole heap faster you also need to install protocol buffers or protoc so these are the formats that tensorflow saves the models in and last but not least you need to install the tensorflow object detection api so this is available through github ready to do it let's get to it so in order to install the tens flow object detection api there's five key things that you need to do and it's best that you complete them in this order as well because you're going to avoid any issues so first up what we need to do is install python and to do that we're going to be using anaconda then what we're going to be doing is installing the visual c plus build tools and just to hedge off any issues we're going to install that using visual studio then we're going to install cuda and cud and n now this step can be skipped if you're not using an nvidia gpu if you are i highly advise you run this step because it's going to make your deep learning models run a whole heap faster then we need to install protox so this is going to help us work with protocol buffers we'll delve into that a little bit more once we get to that step and then last but not least we're going to be installing the actual object detection api from github so first up let's not waste any time let's go on ahead and start installing python so in order to install python we're going to be using anaconda and the reason that we need python is so that we can use tensorflow inside of a jupyter notebook now in order to install python we're going or in order to grab our anaconda version we're going to go to this link so repo.anaconda.com forward slash archive now again all of these links are going to be available in the description below so if you don't catch it from here just go and check the description it's all going to be there so if we copy this link and go to it so in this case i'm already at it you're going to end up in a screen that looks a little bit like this so it's a whole bunch of link files now the file that we're looking for in particular is going to be the anaconda 3 2019-4.07 version so this is going to give us python 3.7 i think dot 3. so this is just going to make a little bit easier now i think you can use 3.8 successfully so i've tried that as well seems to work successfully so if you're watching this sometime in the future just use the latest version and then you might need to play around with some of the other versions but in this case we're going to be using 3.7.3 because i've tested it and it works so to find out what we're going to do is just hit find and then we're going to search for anaconda 3 dash 2019.07 so if you just type that in and you can see we've got a whole bunch of versions highlighted there so in this case you've got a whole bunch of different distros so we've got a linux version a mac os version a windows version and a windows 64-bit version now depending on what type of machine you're installing this on just go on ahead and download the version that you need so i'm running on a windows 10 machine which is 64-bit enabled so i'm going to be downloading this one now in this case i've gone ahead and pre-downloaded all of these versions to make our lives a little bit quicker so if you're doing this for the first time just click that link and go on ahead and download it in this case i can cancel because i've already got it downloaded and we can open up our download folder so throughout this tutorial or throughout this video we're going to be referring to this folder quite a fair bit i've just got all the stuff that we need to install but you can see anaconda 3-2019 dash windows x8664 that's the exact same file that we've got here to install it all we need to do is double click it and this is going to run us through a wizard then we can just hit next i agree in this case we're going to be installing it for all users if you don't want to install for all users that's fine we're going to hit all users this time and hit next and then we're going to select yes to get through user access control and then in this case we're going to be installing it in our c drive and then forward slash program data anaconda 3. then hit next and then we're also going to add it to our path environment variable so this is just going to make sure that it's available from our command line and then hit install this might take a little bit of time we'll be right back so that's anaconda installed then we can just hit next next and then we don't want to open up these links and then just hit finish so now the way to test whether or not this is completed successfully is if you open up a command prompt or if you're working on a mac machine just open up a terminal if we type in python we should now see that anaconda is popping up and indeed we've got version 3.7.3 that's all good so step one is now done so we've successfully installed python now the next thing that we need to do is install the visual c plus plus build tools the reason that you need to install this is because tensorflow relies quite heavily on c plus plus in fact it's written in c plus so we need to make sure that we have those compilers installed now we're going to be using visual studio to install these build tools and the reason for that is because in our next step we're going to be installing cuda now cuda it needs visual studio in order to work successfully so what we're going to do is going ahead to this link so visual studio dot microsoft dot com forward slash vs forward slash community so if we copy that go to that link and again you can see i'm already there what we're going to be doing is installing or downloading visual studio so if we download visual studio you can see it should pop up down the bottom in this case it's downloaded now again i've already got this available in our downloads folder so we've got vs community and then just a bunch of numbers i'm assuming that's the build number now in order to go on ahead and install this again there's a wizard so we just need to double click hit yes continue so first up it's going to start downloading some installers and then what we're actually going to need to do is download the entire visual studio package this is roughly 1.9 gigs from last i looked so it might take a little bit of time to download but that's fine we'll just wait for it to download and hit install all right so that's the visual studio installer installed then it's actually going to open up the installer and then we're going to be able to install visual studio itself so not the installer that's a bit of a mouthful but basically there's like a installer interface that installs first and then you actually go and install visual studio as i said there it is and so there's a bunch of stuff that you can select here now what you definitely do need to install is desktop development with c plus plus so you can see down here there's this little bit here you just need to tick that it's about 7.37 gigs that it's going to need overall when it downloads it should be about 1.9 gig so if you just make sure you select desktop development with c plus plus then hit install so you should see in this exo again it's about 1.94 gigs so this is going to download and install at the same time so roughly it takes a at least a couple of minutes to install depending on how fast your internet is so as soon as that's finished installing we'll be right back so that is visual studio now installed so you can see it's going to open up this sign in session we don't need to do that we can just hit exit so that is step two now done so so far what we've done is we've installed python and we've also installed visual studio so if you actually take a look now and type in visual studio you can see that we do in fact have visual studio 2019 there cool so that's now done now the next thing that we need to do is go on ahead and install cuda and c-u-d-n-n now we need some really specific versions for this so for cuda we need version 10.1 and for cu dnn we need 7.6.5 now cuda and cu dnn are optional but if you've got an nvidia gpu i highly recommend you install them because they're going to speed up your training a whole heap now in order to install cuda the first link that we need is this one here so it's https forward slash forward slash developer dot nvidia dot com forward slash cuda dash 10.1 download dash archive dash base so if we go to that link and where we'll basically end up is at the nvidia developer site and from here you can download the cuda toolkit in this case we want the windows version but you can choose your different operating system depending on what you want to use in this case it's got the 64-bit architecture there and we want windows 10. and in this particular case we're just going to hit exe.local if i make that a little bit bigger you can see that a bit better so in this case if we select that you can see that there's a base installer that opens up down here in this case is about 2.4 gig so we can hit download and that will start downloading in this case we don't actually need to go and download it because i've gone and downloaded it already so if we open up our installation folder i've already got it there so you can see in fact we've got cuda 10.1.105 and that's for windows 10. so same thing that we had down there in this case all we need to do is double click it and first up what it's going to do is extract all the files and then it'll actually run through the installation so in this case it's finding an extraction path just make sure that this is a path that's available it doesn't really matter where you put it initially so we can just hit okay okay so you can see that it's now extracted now what it's actually going to do is check system compatibility you'll then need to hit the license agreement choose your options so whether or not you want to install the express or advanced version we're going to go for express this time then run through the install steps and then you're done so in this case we'll hit agree and continue in this case we want the express version so just hit next it's then going to check a bunch of options and prepare for installation so this should be relatively quick and then once that's done we can actually start setting up cuda now just a key thing to note that when you're using 10.1 make sure you use cuda 7 or 7.6.5 it's just going to make your lives a whole heap easier because those are the versions that tend to work together so sometimes what happens is right at the end when you want to use the tensorflow object detection api it'll use q find pick up 10.1 but then it won't pick up the correct version of cu dnn so make sure you use these versions if you're setting it up in this environment alrighty so that's cuda now installed so we can just hit next and then in this case we don't need to launch any samples or documentation so we can close that now super important thing to note so once you've installed cuda 10.1 you want to be using cud and then 7.6.5 so this is just going to make sure that you don't have too many compatibility issues when you go to use the tensorflow object detection api so in order to grab that version you just need to go to developer.nvideo.com forward slash idp forward slash cud and then archive so if we copy this link it's basically going to take us here now a key thing to note in order to download cu dnn you need to be part of the nvidia developer community so say for example i log out and i go to that link again what you're actually going to need to do in order to download these if i actually scroll down to find cud and n 7.65 10.1 so if i actually want to go and download this i'm actually going to be prompted to join the nvidia developer program now this is free so you can just hit join now follow the links and it's pretty straightforward in this case i've already got an account so we can just go on ahead and log in and then you can see that it's going to say that we can now continue to download the file so it's 7.6.5 windows 10 x64 so we can go and download that so in this case i've already got cu d and n downloaded so we can just extract it so in this case you can see it's the same file so cdn 10.1 in this case we've got 7.6.5 so if we extract that here and hit extract what we now need to do is copy our cudn file so in this case if you actually step in we've got a whole bunch of cud and n files inside of here we need to copy these into our cuda folder so if we open up where we installed cuda so i'm just going to open this up inside of a new window and if we go to program files nvidia gpu computing toolkit cuda 10.1 and if we open this up you can see that at the moment we don't actually have any cu dn files in here but what we're basically going to do is take these cud and then 7.65 files and paste them into our cuda folder so in this case if i grab my bin file so you can see here that i've got cudn 64 underscore 7.dll so i'm going to cut that or copy that and paste it into its respective file inside of my cuda folders so i'll take my bin file and paste it into my bin folder inside of cuda and hit continue and then we'll do the same for the rest of the folders so we'll grab our includes file and paste that into our include file inside of our cuda folders and then last but not least we just need to do our lib file so in this case if i step back into cuda or cdn you can see that again we've got an x64 folder similar to what we have in our cuda folder so if we open that up we're just going to take our cudn.lib file and then paste that into there as well so that's about it for setting up scuda and cu dnn so what we've now done is we've installed cuda 10.1 and we've also installed cudn 7.65 now the next thing that we need to do is go on ahead and install protox so this is step four so step four is installing protocol buffers so why do we need this well tensorflow graphs are represented as protocol buffers now in order to work with these graphs we're going to install or set up a library called protoc so this is going to help us work with it when we go to install our object detection library now in order to get to it what we basically need to do is go to github.com forward slash protocol buffers forward slash protobuf forward slash releases so you can see those all here i believe i'm missing an s there should be this should be releases terrible formatting that's fine so again the link is in fact github.com forward slash protocol buffers forward slash protobuf release it so if we actually copy this and paste it in here again you're going to get to the same page now in this case you'll start up at the top of the screen so protocol buffers v3.1.4 and if you scroll all the way down you can see that we've got all the assets here so there's a bunch of different installers now the one that we need or the one that we're looking for is protock and then the one that's applicable to our operating system so you can see there's a bunch here the one that we're going to use in this case is protot 3.1.4 or 3.14.0 win64.0 so this is going to be the one that allows us to work on a 64-bit windows operating system but you can see there's linux installers and there's also an os x installer as well now what we're going to do is download protoc 3.14.0-win 64.zip so this is going to download and then we can set this up now this is relatively straightforward so in terms of installing the protoc installer we just need to grab that download so in this case i'm going to grab this and then i'm going to put this where i actually want to have it installed so i'm going to cut that out and then i'm going to go into my local disk or at my c drive and then i've got this folder where i tend to put all of my random installers and stuff so and it's just called additional packages so if i open that up you can see i've got label image in there already this is from a previous video i'm going to paste protock here so this is step one now what we need to do is extract it here so we're going to right click hit extract all and i'm going to rename it so it's just going to be protock and extract and you can see that we've got everything for protock here now the last thing that we need to do is just make sure that we add proto to our path on our windows machine so this is going to make sure that we're able to find it when we go and use that particular command to do this we just need to right click our pc hit properties and in this case it's going to open up then we can click advanced system settings this is just open up on my other screen and then select environment variables and then what we're going to do is update our path so this basically means that when we go and use protoco on our command line we're going to be able to find it so if we hit edit and then we're just going to copy this path so in this case because i've extracted it to my c drive and additional packages and protoc that's where i want to point it to now what we actually need to do is point it to our bin folder so if we copy this entire path and paste it into our path you can see that we've got it there so basically what you want to do is you want to add another directory or another path to your protoc bin folder so in this case we've just added c colon backwards slash additional packages backward slash pro talk backwards bin if you put pro talk in a different folder say you put it in a folder called random stuff it'd be c colon backward slash random stuff backward slash pro talk backward slash bin in this case we can hit ok and ok again and okay that's protock setup so that's step four now done so we've now completed steps one through to four now the final and most critical step is actually installing the tensorflow object detection api now in order to do this what we're going to do is we're just going to clone the repo so in this case here we've got a reaper which is the tensorflow models repo but again if i paste that link in here this is all of the stuff that you're actually going to need to work with the object detection api so there's a bunch of stuff in here now really what we're going to be focused on is if you select research and go down to object detection we're mainly going to be working in this space here but what we're going to do to begin with is we're going to clone this repo now i'm going to open up a command prompt and i'm going to do this with administrator privileges because we're going to be installing some stuff in a sec so if i right click hit run as administrator and hit yes you can see that this has opened up a command prompt if you're working on a mac it's going to be your terminal now in this case i'm going to navigate to my d drive and then what we're going to do is we're going to clone down that model's github reaper so to do that we can just type in git clone and paste that link and hit enter so this will take a little bit of time to download but as soon as that's done we'll be able to start setting everything up alrighty so that's the github repo now cloned we're on the final stretch now so what we're going to do is we can take a look at that so you can see that i've got a bunch of stuff if i type in ls now key thing to point out is that on this windows machine i've got something called git bash installed so if i just bring up git bash this basically allows me to use git commands or bash commands inside of my windows machine now if you want to go ahead and install this you just need to go to getforwindows.org and hit download and install that just going to make your life a little bit easier when you're transitioning between linux machines or mac machines and windows so i tend to use this on a lot of the machines that i set up now in this case what we're going to do is we're going to go inside of our models folder so we can just type in cd models and then from that so again keep keep in mind that we've got gitbash installed here so this is going to make our lives a little bit easier and then what we're going to do is navigate into our research folder and then from here we're going to type out a prototype command so this is going to allow us to start working with our object detection library so i'm going to write out this command and then we'll take a look at what we've written all righty so that's our command so in this case the first part of it is protox so as i said we're using the pro talk library and then what we're doing is we're typing up object underscore detection forward slash protos and then star dot proto then we're passing through a flag so dash dash python out equals and then dot so this means its current folder so this command is from the official object detection tutorial but again i'll link to that in the description below so if we run this then the next command that we need to do is actually go on ahead and copy our python setup file if you're running in windows without gitbash it's going to be a copy command in this case we've got git bash installed so it's cp so let's go ahead and write it up okay so in this case what we're doing is we're copying the setup.pi from object detection forward slash packages forward slash tf2 into the current folder so in this case we've got cp the folder where our setup.pi folder is and then dot so if i actually go ahead and open that up so remember we cloned it into models so if we go into research object detection and if we take a look at the rest of our file path it's object detection forward slash packages forward slash tf2 and then setup so basically what we're doing is we're copying this source part or this setup file into our current directory so if we do that then the next thing that we want to do is actually go ahead and install it now because we installed python we're going to have pip enabled so we can pip install so to do that we're going to type out python dash m pip install and then the current directory so this is going to pick up our setup.pi folder and go on ahead and run that so if we run this this is actually going to install all of the dependencies that we need for our object detection library so let's go ahead and install it so this is actually going to install tensorflow opencv and a whole bunch of other stuff so this might take a little while but as soon as that's done we'll be able to test it out and that is it installed so we've now successfully gone through steps one through to five so in this case we've installed python we've set up our visual c plus plus build tools done kudo and cud and then done protoc and we've now gone ahead and installed the tensorflow object detection api and you can see it's gone and installed a whole heap of libraries now in this case what i've actually got is some of the code from our face mask detection tutorial i'll include a link somewhere above if you want to test it out what we're going to do is see if we can at least get to the training step so this is going to make sure that we can actually go ahead and train our deep learning models so in order to get to that i've just got it inside of my d drive and inside of my youtube folder and what we're going to do is we're going to open up a jupiter notebook in there and again the jupyter notebook command will come from installing anaconda so we can now open it up and i've actually got a file called tutorial again i'll include a link to this tutorial in the description below if you want to test it out so if i actually open up tutorial and step through this basically what we're going to be able to see is whether or not the tensorflow object detection walkthrough has worked so basically first up what we're going to do is step through our setup parts and again this entire tutorial is going to be available in the description below so you'll be able to grab this jupyter notebook and test it out now the associated video to that will be linked as well so if you want to check that out by all means do so so we're going to keep stepping through and the first set which will tell us whether or not this has sort of worked is whether or not our tf record lines have worked so that looks like it's been created successfully now if we step on to step number four if we go through that looks like it's okay for now now this is the critical bit so you can see here that we're importing object detection utilities so this will tell us whether or not we're actually able to import that successfully and pretty often when you're using the object detection api this is where you might encounter some issues so if we actually step through that it doesn't look like we've had any issues there yet so if we keep stepping through by hitting shift enter looks like we've successfully written out our config now this is the key bit where we want to see whether or not this is going to work so in this case what we're going to do is we're going to copy this command and this is actually going to go on ahead and start training our model now if we've successfully installed cuda and cud and then successfully and the object detection model successfully this should just work and start training so if we copy that and open up a new command prompt what we're going to do is navigate to the same folder that our notebook is in and if we run that command now ideally what should happen is a bunch of stuff should show up on the screen and eventually we're going to get our initial loss metric so this is going to tell us whether or not our model is successfully training so let's paste that in hit enter so if we just scroll up there it looks like it's successfully imported cuda it's imported envy cuda and let's take a look to see if it's imported cu dnn tensorflow is optimized it doesn't look like we've got any issues and it looks like it's picked up cu dnn so that looks like it's successfully using our gpu and it should be training relatively fast so ideally what we should see is once our model starts running we'll get some loss metrics and we'll see our time per step and there you go so our model is now running and you can see our time per step as well as our loss so again it's running pretty quickly because we are now in fact using the gpu so you can keep letting this run and eventually you can finish off the rest of that tutorial but if you've got to the end of this video by all means give yourself a pat on the back because you've now successfully installed the tensorflow object detection api so we've done quite a fair bit so if we take a look back what we've actually gone and done is we've installed python we've set up our build tools we've set up cuda and cud and n which is not normally an easy thing we've also set up protoc and last but not least we've successfully gone and installed the tensorflow object detection api and that about wraps it up thanks so much for tuning in guys hopefully you found this video useful if you did be sure to give it a thumbs up hit subscribe and click that bell so you get notified of when i release future videos and if you have any issues installing the object detection api by all means drop a comment below and i will get right back to you and give you a hand thanks again for tuning in peace you
Info
Channel: Nicholas Renotte
Views: 51,095
Rating: 4.9390244 out of 5
Keywords: tensorflow object detection, install tensorflow object detection, install cuda, install cudnn, install tensorflow
Id: dZh_ps8gKgs
Channel Id: undefined
Length: 28min 3sec (1683 seconds)
Published: Sun Dec 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.