Raspberry Pi Object Detection Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
i have a fun raspberry pie tutorial for you today i'm installing tensorflow lite on my raspberry pi and then using that to do some image classification this should work with raspberry pi 2 or newer let's jump right in we're following along with tensorflow's example library here tensorflow lite python image classification example with raspberry pi i'll link to this github page in the description and i'll also include all the commands in the description okay scrolling down what can we do real time image classification if you have a coral usb accelerator you can use that i do not you don't need one not required but it does increase the speed of this project okay before we start you need to set up your raspberry pi if you haven't done that i made a video for just specifically you that you can go watch watch that set up your pie come back and then we're going to get going first thing i'm going to ssh into my raspberry pi if you want to do real-time video classification and see the image with it you'll need to plug your pi into a monitor but to do the installation just because i got my recording software going here i'm going to do it through ssh and then at the end show you that it's working with the raspberry pi connected to a monitor i got my terminal open here so i'm going to ssh into my pi ssh pi oops ssh pi at raspberry pi then my password oh yes first time ssh in my password if you're following along with your raspberry pi connected to a monitor just open up a terminal what's first we gotta upgrade our raspberry pi sudo apt-get update and now sudo apt-get upgrade sudo apt-get upgrade and then dash y so i don't have to type anything and that took about five minutes so now we're going to set up a virtual environment check your python python-v i'm running python 3.9.2 if you're running python 2 then maybe try running the command python 3 v and hopefully that works out for you so now let's set up a virtual environment let's create a virtual environment you might not have a virtual m package installed so run the command sudo capital h python 3 dash m pip install virtual m all the commands are going to be down in the description i already have it installed so it went quick for me it'll be a little longer if you have to install it now let's make a project directory mkdir make directory project now if we list our directories and files we see the project directory right here and let's change into that directory cd change directory projects now we're in the project directory and it's time for us to create a virtual environment this will keep all our python packages contained so they don't pollute any other python environments that we have going on all right here we go whoops python 3-m virtual m awesome so now ls we see that m is right there and let's activate our environment with the command source and bin activate and then all of a sudden we get our m for in our environment so now we can install python packages and they'll only be in our python environment here so in order to get back to these packages say you close out your terminal and come back you have to reactivate the environment in your project directory using the command source m bin activate if you're using a pie camera i'm not i'm using a usb webcam for this but if you're using a pi camera let's run the command pip install in quotes i don't know if that's necessary but i do it pi camera array end quote scrolling down now let's install the tensorflow lite runtime this is so easy you ready this command right here python3 dash m pip install tf light dash runtime and we have tensorflow lite installed if you hop into a python interpreter python now we're in a python interpreter and then do import tf lite underscore runtime it's imported and let's check our version tf light underscore runtime dot underscore underscore version underscore underscore boom tflight version 2.7.0 quick to get out of that and now let's actually run some object detection this section is all complete let's get the example files copy that i'll link this in the description paste over here all right copy this first line to get into our new project directory and then let's run the setup shell script that tensorflow made for us okay so now we're here and we think this is our final thing run the example this should work right but we're gonna get an error all right what does it say libsy blasts so can't whatever it doesn't work so what you need to do is run the command sudo apt-get lib atlas dash base dash dev enter oh my gosh sudo apt-get install lib atlas bass dash dev yes so what we just installed lib atlas atlas stands for automated tuning linear algebra system something like that but linear algebra very important for machine learning stuff i'm going to go into my raspberry pi now and show you that it works with the real time classification okay i got my raspberry pi dot pi open i'm recording with my phone so sorry about the quality and now we got activate our python environment first cd into project and now source m bin activate see the m so we're in our project directory with the environment created and now we're going to get to those files wherever example.pi or what's called classified.pi is located cd examples light examples image classification and then raspberry pi now list what's in there okay and there we go there's our classified up pi file so let's just run that python 3 classify dot pi hello that's me okay let's see hammer okay what else do i got oh is it gonna get this one rule i saw it pop up yeah rule there we go okay and doesn't know what a mug is that is the question water jug close coffee mug there we go and now let's get meta that is not saying raspberry pi i'm a little disappointed but you can see that it works and there we go we got image classification there are ways that you can modify this script for example there are different models that you could use or you could take the code that's in classify.pi and then use it for whatever application maybe when it detects a hammer it wants to say nail or i don't know whatever fun thing you're trying to do anyway if you made this script or need help with it or have a request for any future video the comment section is where you can reach me subscribe for more raspberry pi tutorials and happy coding
Info
Channel: Sam Westby Tech
Views: 74,018
Rating: undefined out of 5
Keywords: raspberry pi, tensorflow, tensorflow lite, machine learning, raspberry pi 4, computer vision, python, object detection raspberry pi, object detection on raspberry pi, install tensorflow lite on a raspberry pi, object recognition, object recognition raspberry pi, object detection in python
Id: NPXBRX7N3ec
Channel Id: undefined
Length: 9min 19sec (559 seconds)
Published: Fri Mar 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.