Tensorflow Lite with Object Detection on Raspberry Pi!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey welcome back Ben again today we're taking a look at how we can install tensorflow light on the Raspberry Pi and do some simple object detection okay let's jump right into this so I'm going to assume for this tutorial that you already have a Raspberry Pi set up and ready to go in my case I'm just using VNC to virtually see or remotely see my Raspberry Pi which is just right next to me on the desk next to me but um it'll be easier to do it this way since I don't have to hook up a monitor and easier to screen record so but if you are interested in learning how to set up a Raspberry Pi remotely and have a setup like this I recommend checking out my past video and I'll link it or put a card and I show you how to do exactly that but all right let's get started here so there's a few things we need to do unfortunately for us the setup is pretty easily pretty easy I should say okay so what we're going to do first is that we're going to clone a repository from GitHub from the tensorflow example file and I have the link with me already but I will of course be sharing all the links and resources I use in the description below so I'm just in uh the default directory here but I think I will actually probably put it on the desktop so I'm just going to CD into the desktop feel free to put yours wherever you want and I'm just going to do a g clone into here let me paste in the URL and it's going to create the folder examples and we can see it popped up over here and if we want we can take a peek but for our purposes we're just going to be hanging out in here okay so now that we have that examples folder what we want to do in the uh command window here we want to CD into examples so we're just going to do CD examples and now we're in this directory but just in the command prompt so I'm going to make a virtual environment uh you don't have to if you don't want to I just have other things I do on this pie so a virtual environment is very helpful to keep your code and packages separated um so I'm going to show you how to do a virtual environment but you can skip this step if you'd like so first we're going to make sure we have the package for it so that's going to be for us Python 3 oops gem PP install virtual environment or virtual EnV I believe believe it is make sure yeah and it might yell at me since I already have it oh it seems like I have an extra V on there do that instead helps if you uh spell it correctly all right there we go now let's get that and mine might actually just update or might put it on my uh global system okay there we go so now we have the ability to make a virtual environment so while we're in this desktop examples let me actually clear the screen real quick so we're still in examples we're just going to make a new environment so you're going to want to do this based on the version of python you have on your system and you can do that by doing python 3-D version and then we'll show you what version we have so I have 3.7.3 so that's what I'm going to use so to do that we are simply going to say python 3.7 dasm and then we're going to say virtual environment or ven as like to say and then the name of the virtual environment you want to use so I'm just going to say uh TF for tensorflow sure why not you can name it whatever you like a lot of people will just call it EnV EnV all right so now it's made and if we do a list here we're going to be able to see that there's actually a folder named TF now so to activate this ver virtual environment cuz we've made it but we haven't activated yet to activate it we want to say source and then you want to use the name of the virtual environment you made so for me it's going to be TF do SL bin slash activate if you do that you're going to see in your command prompt it changes at the beginning and now it's going to show you that we're using a virtual environment right here which is exactly what we want cool so the next step we have to go into where the uh setup folder or setup file is sorry as uh tensorflow includes a handy file for us that installs a lot of things that we need so that's going to be uh we're going to CD into I'm pretty sure we're in the right directly let me make sure yep so we're going to be going under light so we're going to say CD light and then it's going to be under examples so let's jump in there if we do another LS you can see all these different examples that they have uh today we're going to be doing object detection but feel free to to play around with these cuz they have a lot of cool stuff so we're going to CD into object detection another layer deeper we're going to take a look and we have these different versions so we're going to use the Raspberry Pi so we're do CD Raspberry Pi all right so now we're in here and there's bunch of more stuff so what we want right here is the setup.sh which is a shell script so to do that to use it we're going to say sh and then setup Dosh if I could speak today all right we're going to give that a second and it might uninstall some of your stuff as you can see here as it's very particular about the version types of things we have to use here so give that a second okay so takes a while to uh set up some time but we should be in clear now that's finished going and it looks like no errors yay that's fun all right so now we should be able to run the example script so the name of it if we go into LS here so you can see we actually downloaded a few things too we got uh one of the example models that we can use what we want here is this detect. so for this one we're also going to have to uh describe or tell it which model we're going to use so we're going to say python tech. py I believe we just got to do das Dash efficient let me back this up oops oh you know what it's actually uh you got to describe the model before I forget it's Python 3 there we go okay so detect piy and then we say model or sorry Das Das model and then we're going to use the the uh name of the model so it's going to be the efficient debore light z. tfight we're going to go like that and yeah so we're probably going to run into this error where we get some sort of error about this glib I call it glib the glib cxx where the version can't be found but fortunately for us thanks to great people on stack Overflow and I'll also link to where I found this we have a fix for this all we have to do is actually downgrade a package called TF light support so all we got to do here say python curs out the way M pip install Das D upgrade we're saying upgrade but really it's going to replace the version we already have say upgrade TF light- support equal equal get the number right 0.4.3 there we go so if we do that this will probably also take a second but we're going to uninstall what we currently have which you can see is version 4 uh 0.4.4 and there we go so now we have 043 cool so now if it all works well we should be able to run that file again I forgot where it went here it is so detect. piy let's go and all right here we go there's me we got our little window here you can see the very familiar B bounding bounding bounding bounding boxes I forget the name that we normally see with object detection I have a little camera over here it's a little laggy which is to be expected but if we pick that up you can see you can see there I am I'm a person and it thinks that's a clock back there which is fair it does look like a clock it's not a clock but it looks very clock like um here I can get my phone it should know what my phone is if I hold that up there yep cell phone so this is very disorienting to watch myself like 5 seconds late cell phone I'm going to reach across the microphone real quick all right if I have a Xbox controller yep it's going to see it as a remote which is great if I pick up my keyboard you see [Music] that I said if I pick up my keyboard there it goes a little too close to it it may be hard to see the uh thing oh now it thinks it's a laptop oh cuz my monitor is next to the keyboard so if you look at it sideways it definitely looks like a laptop okay what if I go like this though I definitely had this before there we go keyboard okay there we go so it's definitely not the uh the best model but then again we are running on a Raspberry Pi and this is just an example mod example model so if we want to close this we're just going to go back to our Command Prompt and we're just going to hit contrl c a few times and there we go there we go it ended cool so for that model we put in this model efficient debt you can download other models uh pre-built models that they have that you can put in there and you can detect different things you can put a custom model in there it's just got to be a TF light but uh yeah if you already have a model there are actually ways to convert them and I do plan on making a video about that either next or sometime soon as we already have videos on my Channel about how to make a model for your standard tensor flow so perhaps we'll make a video about how to convert that we'll see let me know in the comments what you would like to see and you know we can do a bunch more stuff with this Raspberry Pi tensor flow light stuff but otherwise that's going to be it from me again leave any questions comments concerns down below and if you can give me a like that helps so much but otherwise thank you for watching and I will see you in the next [Music] [Music] one [Music]
Info
Channel: Lazy Tech
Views: 19,270
Rating: undefined out of 5
Keywords: tensorflow 2, object detection, tensorflow 2 object detection, object detection api, numpy, python, machine learning, object recognition, custom model, webcam object detection, detect objects on webcam, webcam, ai, Artificial intelligence, Neural network, custom object detection, google colab, nvidia, Image classification, Video object detection, tensorflow lite, tflite, raspberry pi, raspberry pi object detection, Webcam
Id: kX6zWqMP9U4
Channel Id: undefined
Length: 11min 31sec (691 seconds)
Published: Sat Oct 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.