How to Install TensorFlow Object Detection in 2020 (Webcam and Images!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey you welcome backspin again today we're taking a look at tensor flows object detection API in trying to detect objects and images and using our webcam so if you're watching this video there's a good chance we're coming from sent Dex's youtube tutorial series where he goes over how to do all this in a six-part video tutorial I even personally watched his video since I've been working on a research project where I have to use object detection but if you're like me you might have noticed how it's kind of out of date and a lot of things don't work on the modern PC so even if you're brand-new it this not and haven't watched his videos we're gonna be starting from the very beginning and hopefully anybody should be able to follow through and I'm gonna be hopefully fix some things that you may be experiencing now so to start we're gonna need to download the tensorflow model directory repository off github so do that we're just gonna grab their link and I'm going to open up my folder my personal folder it's gonna be called models so I already have a models folder in here from when I was working on this let's just rename this one real quick models to I don't know okay cool so let's do this let's open up a command prompt and see we're just gonna use git clone and we're gonna clone it right into this directory so we can see down here we have models and models too and this is gonna be downloading might take a couple seconds this is using git if you don't have git I recommend getting get that's gonna be helpful otherwise you can go to the website and you can click this big green button here and you can just download the zip file just like that and it's the same thing but since I have git I'm just gonna use that it looks like we're still downloading it so while we're waiting for that I'll talk about the next part we're also I recommend using anaconda if you don't know that is it's a kind of command prompt you can use to create virtual environments which is really help for keeping dependencies packages your projects all in one place and it's helpful to just keep things organized I really recommend using that as it's what I'm going to be using from now on so to start let's open up anaconda I'm gonna go over how to download and install anaconda but it's pretty straightforward I also assume that you have a anaconda and B Python installed since it's gonna be kind of obvious and says you're both gonna be running in Python so we're gonna start anaconda in administrator mode it looks like our models directly finished let's take a quick look at that models so this'll should be everything you have in here all right so now we're in anaconda we're gonna want to create a new virtual environment to do that we're gonna say conduct create and for name and then the name you want to name it so let's call this naming things is hard isn't it let's just call it object I don't wanna give it a long name let's go object okay so it's gonna go for a second we're gonna click yes not click ok so now we've created it so we're just gonna say activate okay I already forgot I call it an object that's what it okay now you can see over here we're in the object directory instead of base so whenever you work on a project you want to make sure you're in the right one and I've done it countless times where I'm like why isn't this link working he was working yesterday and I realize I'm on the base of route and I'm not in the virtual environment I set up because when you install packages they're gonna stay inside that virtual environment so now that we're in object there's gonna be a few things we're not gonna need to install I have a list kind of a hand list of things we need to install on kind of a tutorial been writing for myself so we're gonna need this big list of things right here so actually I'm going to copy and paste it ain't thinking about doing that all right let's just do that so we're gonna be installing tensorflow 1.15 tensorflow 2 does not work with octave detection unfortunately I believe they're working on a new version for it to work but right now we have to use version 1 so I'm just going to use 1.15 we need LX ml pillow matplotlib Jupiter context library 2 scythe on and TF slim so this is download all of those at once and it looks like yeah so for me I since I have some of these on my system already all these you're gonna see that requirements are already met for you it's probably gonna take a few minutes I'm trying to do this as much from scratch impossible but I didn't want have to uninstall all my libraries and it takes a while so for you we might just take a minute so now what we want to do is we want to move into our correct directory which is our models directory so where do we have ours ours is an oops bring users okay so we need users been models we're gonna go into research so now what we need is we need Pro TOC so we're gonna go to this website here here we go so we're going to need Pro TOC 3.4 there is a newer version now but three point four is the last one that works correctly well there may be versions in-between that work correctly but three point four is pretty much the sweet spot they just want to be in so we're gonna scroll down and we're just gonna get pro TOC three point for Windows 32 so I already have it downloaded so I'm just gonna open up my downloads folder okay good downloads okay here we go make sure your max recording okay I'm recording scared of that alright downloads okay so we have Pro TOC here that we can open that up and what you can do let me delete these old files from it so you can see how it looks delete delete delete so we just want to extract it oops extract it here here we go and it'll probably put it down for a long time ago because zip folders are weird but otherwise it'll be right next to it so what we want we don't need any other stuff we just need bin and we have our pro Toxie so what we want to do with that we want to open up our models go into research and we just want to drop it into here that's gonna make our life easier so now that we have that we're going to okay so make sure we're in our research file we're going to grab this command this is going to compile our pro tunc oops I grabbed a little too much in there all right so if you get this warning line that means you're good if that didn't happen that's not good um the best but I have a lot of people get this error on send Texas video I'm the best way to fix this is to have it in the research folder that we're in right here originally he says to put it somewhere else but if you keep it in here generally this problem gets fixed a little bit easier so if you're getting that problem make sure you're in the research folder and make sure you're actually in the directory research when you run it otherwise you can use the seek man and you can put the directory in there but it's easier if you does use research to begin with so now get my short list up here okay so we're gonna run this so that we can run it online and on our local PC at the same time or not the same time but either/or so we need to do make sure we're still inside of research so we need to run Python set up dot OOP set up dot pi build all right that did not run why aren't you running my name is a Python 3 build no I think I might have built it earlier so it might work still otherwise you should say Python setup dot pi build make sure I'm doing that right yeah ok I'm doubting myself here now all right so after that has built say install and is doing that why is it doing that I'm gonna go ahead and continue with this and make sure that that's actually gonna work I did just do this earlier on a different environment different folder so that might just be why but I guess we'll continue and we'll just see what happens so now we are going to get e we need a PI cocoa tools that's what we need so I'm gonna do pip I and pip install PI cocoa tools and let's see what its gonna say today okay so it's already satisfied so that's probably because I just downloaded it but if yours does not work which if there's a good chance it won't we want to run this command instead the PIP install and then it's this github directory and that what that does is downloads the wheel file that you need instead because when you deny a download PI Coco Tools it's a posting it from siphon I believe which will be installed but a lot of times it doesn't work correctly so if it doesn't work for you just do this one with the wheel file so it downloads the wheel file you need and it doesn't automatically I'll make sure to have this in the description so next we want to open up we're actually almost there so when you want to open up the anaconda or not in a can of sorry we want to open up Jupiter which is where we're gonna receive all of our programs so we can stood Jupiter my notebook and we'll see what that says yeah okay so this happens where you get an error it's probably because anaconda and Jupiter notebook is a little funky so instead to fix that you can say Conda install Jupiter and it might take a second and we're gonna say yes and sometimes if a package or a certain pip doesn't work just using pip try using Conda since Conda will install it like into the base of the environment instead of just as like a Python package so we're gonna wait for this for a second and then there we go so now we should be able to say Jupiter notebook there we go okay so let's see we need to I think I opened it when I was in the research file or research folders or it was here it is ever detector and we need cohabit Oriels if you couldn't find it before it's like if you had looked for it before following send X it's because it's under collab tutorials now instead of just under object detection so if you can't look if you can't find it to make sure it's object detection collab tutorials so once we're here we just want to no object detection tutorial and from once we're here this is we're pretty much at the end for this part if we want to run it we can press sell then click run all smile checking my notes make sure I didn't miss anything on the way here okay it's probably going to take a minute to run Cinci which makes sense I suppose I'll decide if I want to cut this or not later well while we wait for this I suppose we can start looking at how to make this run on your local computer which some tutorials do not go over so the tutorial or since this is actually the tutorial from the API so this is the newer version the one that sent Dex and other people use is generally an older version this one was recently updated so to use that old one so I will I wanted to use this new one on the PC but there are some there are some parts from getting errors for it and I haven't been able to figure it out quite yet so what I did is that I kind of edited edited the old version to make it work today in 2020 so what we can do let's go into our folder this is research let's go into object detection so this is where most of the work will be happening so I actually on my own github since I wrote these things these are the files that we're going to be using if I can just I never actually know I have these files on my computer let's just open them up on my computer that sounds a lot easier supposed to do this open window I gotta find them again when you put things all over the place it's not a great organization let's see better yeah it's models - the only problem with this there's so many freaking directories you gotta go through outer detection [Music] here it is updated so we're doesn't it copy this this is the same exact file from the github and it will be updated if it needs to change but for now it works fine so I'm going to use pycharm to edit and run my scripts since I just like how they I also have a built in virtual environment and it's just easier to work with in my opinion so I'm going to open it up with PyCharm before we do that let's see if this finished running no this is taking a while today oh yeah that's why it's uh building everything what's going O yep it's upset with us that we don't have pi coco tools so oh that's gonna make me restart okay so I want to be able to show both versions of this so what I'm gonna do oh yeah okay it's gonna get mad at me for a second so we have to do was that thing I was actually talking about put the other version of Pi cocoa tools kind of what I call it actually object that's what I said object okay I gotta get my command up here pip install blah blah yeah that's exactly what it says oh whoops I accidentally copied in the word needed that's a great command isn't it let's see how that works building wheels oh we might be able to do this set up now I'm wondering if now the that build would work because I was a little confused when it didn't work but I got models Rhys lips so now I'm interested in Oh second sin of that pie filled okay there we go see you so now it's working I was confusable that before how that wasn't doing anything so that we can do is set up that pie install and now everything should be happy I'm a little confused on that before I think it's because yeah relies on heikoko tools so if you're wondering cocoa is stands for common objects and common common objects in context is what I believe it stands for so that's like the default data set model that you're gonna see in a minute when we do all this so now we can do let me open up into object detection so now we should be able to open up Jupiter notebook again look so there's a little all over the place but you fixing my mistakes on the fly as you do okay so now we should be able to run this so run all maybe it'll actually be happier this time it's it's installing stuff that might take a moment still so we can go back to our other file so I'm gonna open up this file inside of the project here as in project it's more like the directory that's already within see a little better all right it's always guns and scanning packages and fix dependencies and because like it hats important yes it is important install your dependencies okay so Ron updated old example so I can compare so this is my updated version as you can see up here there isn't too too much difference between this and the original all the original old version so right here the only difference is that before it was just PLT show and then none of this afterwards but since we're trying to run this on the local machine matplotlib is not set up for a graphical display so when you try to run it it'll run then you won't get any results or output so that's not very useful so by doing this instead we'll actually save the image is that it detects on to a folder so we can pull them up afterwards let's see if this is finished yet there we go so now we can see on Jupiter notebook wow it worked fantastic some nice dogs right there this I wonder if this one feels inferior for being 1% less than this dog alright so this way so again this is the newer tutorial version but we're gonna be going back a little bit to our version so if everything goes correctly this will work on the first try I don't have much hope for because the nature of this thing but this whole projects been the cultivation of hours of me looking up fixes around things trying everything to work mostly fixes come in to setting up your own your own custom model which we will be going over to in another video tutorial if you guys are interested that's a little bit more complicated but it's a lot of fun so let's say they should almost be done running okay oh I forgot yeah so we are so I put this two output into the folder outputs so we can just add a new folder I got to my stuff open detection onto detection so inside of your object action folder and just create a new folder it's call it outputs alright you can call it whatever you want as long as you change the script I just call it outputs in here because why not it's an output I thought that made sense so now we have that new folder we should run this again and it's probably take another minute because that's always useful I hope it I hope I don't look like a liar you guys it's not gonna work here wait and see I've got a nervous now because that's fine okay should be finishing up okay so finish with exit code that's good output there we go so it's the same thing so the percents will change every time because you the machine is detecting it so yeah and this time this person wasn't even detected poor guy so if you want to change what you're detecting I believe we can just go to test images and yeah so these are the two raw images right here so if you really want to you can put in other images in here and you can detect those also even you have to look out for is this line up here just to change the range this is looks for how many pictures are in that directory I believe you also have to rename them yeah so this one's named image of one image too so just make sure they're all named image three image 4 if you wanted to view some like batch Google down like image download or something like that doesn't make sure the name is image 1 image 2 and the more pictures you have the longer it's going to take but also the size of the picture it's like the more more pixels it has the longer it has to go which is kind of obvious I suppose stuff so this isn't what you need to do if you want to do it on your own PC and again I'll link my github in the description so you can just pull this file if you want again it's not a big fix down here and it's kind of janky so if you want to make a pull request and fix it up yourself that's fine by me so now the big thing using the webcam because that's arguably a lot more interesting so again I have another script and of course I closed out where I needed to have yeah I had I had those two I think everything I had those two scripts open I always missed that tab my action the right one yes okay so what did I call it webcam detection that makes sense we're and pop it into our new directory over here and move down here research object detection webcam detection alright we'll see if it's gonna be happy with us since sometimes you'll get these details where it's unresolved reference and usually you can fix that if you set the root source of your project so at least for me and pycharm if you go up here in the corner might be kind of hard to see but I'm on models which is the top directory and then you can do mark directory as sources root and sometimes they can help doesn't always but I guess let's see what happens I don't believe I edited this file this file was good again this is from scent decks his edits on that I really recommend watching his video series if you want to also again this is kind of more updated version so let's run it hi sorry future been here sorry to interrupt I'm stupid I forgot to tell you about another really important part that I forget it's only about so right here we have import CV - so CV to is computer vision - I forgot to mention it because since I have other dependencies on my computer already it doesn't light up red which it normally would for you if you haven't done this before so computer version 2 is another package we have to install but we can't just say pip install CV - because nothing is that easy in life don't blame me I don't know so we have to do instead is we have to install a wheeeeel file so we can do like we gotta pull up here I have the website right here I'll also link this below here we go so this is a list of packages official packages for Python so what we need is where so you need to get one of these open CV packages so you have to get the one that matches your Python version and the bit version so I'm using Python 3 point 7 64 bit so that would be where is it three point seven right here so this would be this package I need right here and I think I already have it downloaded but we'll see in a moment okay I used to have it downloaded we make sure I'm on the right everything save we're gonna open up the file location chilling folder I want to make sure the other ones I have are not the same thing okay so now that you have the matching version we can just say go up into your command prompt again so we need to go into downloads or wherever you downloaded it to so that's gonna be users boom downloads so now we can say pip install and then we can say open CV if you tab it should find the file you're talking about which one oh did I just get I want to make sure I'm using the one I just told you about the res I feel like a liar all right so this should be the correct one you're not support okay so maybe I do need 3.6 I don't remember what version of Python 1 I know I'm the super II helpful today ah and still come am I using 3.6 no I have I have too many packages on here let's just do it on here because this should be 3.7 so prompted zoom out for a second yeah I realized I'm really mad about this Izu m-- I had sumed in my up side you're gonna freak out over is that good my screen for my other tutorials and I forgot to freaking change it for this thing so I'm sorry about that it's all zoomed in ah really just boils grind grinds my gears that everything kind of we need to act I always forget he's gonna tell me what version of Python and then home on 3.8 that's a lie okay okay so if we're in this though I might need to change my well we can try it with 8.3 so this is where it's Oh cuz I pried the contribute file okay I gotta apologize again I'm just forgetting what files I'm using all over the place this would help okay open the CV I don't want the contribute version okay so it's still not that version - it must be there we go okay finally it took so long so I was on 3.8 sorry so you can tell what version Python is by the sea p38 right there that means 3.8 so that's what I'm running I believe does on 3.7 but I'm not at some point so once you do that you should have it up here and everything should work fine and cv2 should be in there okay sorry about that back to past me which is present me which is my bye so the webcam I have for my computer is not great so I don't use it for actual videos like this because it sucks so I'm pretty much just use it only for Audrey detection which doesn't help with my research project because it's not very high resolution and it messes things up so you'll see in a second though there I am yeah so now there should be two of me probably so see I'm a person amazing so you can test it with more thing that you normally use my phone test it but my phone is right here so if I move over yet here's my chair my Legos and all the Legos on my shelf because I like Legos if you couldn't tell you didn't play around with this all you want to try think of other things I could hold up sometimes it's yeah thinks my water bottle is a skateboard and I was like for the longest time I was like why do you think it's a skateboard I'm like all the stickers on it there must have used images that had lots of stickers on it so there we go that's the webcam setup it was pretty easy if you ask me again the this file should work automatically everything you did everything you set up correctly um again oh let's hope you set it up correctly so basically if you just follow the files directory so you have models research out of detection and then you have all the files on there it should work correctly if you're getting errors that say object detection is not what do they call and they've got over here like unresolved references so object ection is an unresolved reference try to set your project directory or the project like base to a higher a higher root i guess we call it a higher folder so if I was running if I was running this inside of the object detection so say there was nothing there was nothing above auto detection at all I could see oh the times you'll get that error so make sure that you set it up as high as you can sometimes you just have to create a new file somewhere else on the higher on and then just say open and file or open in project and then you can create that or fix that problem so recommend that that's a big problem for me too for a while if you get the error no module named TF slim just do what this still has the tensor flow or the Jupiter notebook close that real quick so with a couple fixes we can do if you get yeah so if you get a problem that says no module named TF slim we can fix that we actually already did it but sometimes people will miss it what am i doing activate well the word I'm looking for okay activate so you have to do pip install oops TF slim and well it would help if I could spell correctly there we go okay I already have it installed but I believe in the original video tutorial that centex does he does not use TF slim so that could be something that you missed that was a big problem for people so other than that that's gonna be it for me today I hope you found this useful I wish I had a video like this when I was first trying to do this hopefully I will be doing another video about training training your own custom model so I've been doing that with Lego bricks because I want to try it out to see if I could do it myself for my research project we need to detect game pieces on my game board so just to make sure I could do it right I just did it with Lego something simple and something i am i have plentiful of so hope to see you again next time if you can leave a like subscribe i like to do this type of concept content and i hope to do more that see you next time [Music]
Info
Channel: Lazy Tech
Views: 62,669
Rating: undefined out of 5
Keywords: tensorflow, tensorflow object detection, object detection, tutorial, object detection 2020, python, cython, tf_slim, pycocotools, google, protoc, protobuf, matplotlib, webcam detection, AI, machine learning, deep learning, CNN, artificial intelligence, computer vision, custom object detection, object detection api, tensorflow 2.0, tensorflow tutorial
Id: usR2LQuxhL4
Channel Id: undefined
Length: 30min 42sec (1842 seconds)
Published: Thu Jul 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.