Step by step for Raspberry Pi 3
Welcome to the step-by-step tutorial for running LiveDetect with DeepDetect, directly on the Raspberry Pi 3.
This tutorial need a simple setup, a Raspberry Pi 3B+ with a Raspbian system installed. If you do not have Raspbian installed on your RPi3, please refeer to this tutorial.
Now that your SD card with Raspbian is plugged in your Pi, connect the power cable, a keyboard, an ethernet cable, and an HDMI cable linked to a monitor, for the next step.
Boot your board, then login with the default credentials for Raspbian, the username is pi
and the password is raspberry
. Don't worry if the password isn't displayed on the screen when you write it, it's a common security thing on all Unix systems.
Now, update your system:
sudo apt-get update
sudo apt-get upgrade
If you're prompted for a password, that's still the default raspberry
password.
The next step is to setup the Raspberry Pi for an headless utilization, use the built-in raspi-config tool:
sudo raspi-config
This command will display the following options:
Navigate to 5 Interfacing Options
then activate SSH
and also Camera
if you wish to use the Pi Camera module.
You can then navigate to <Finish>
and go back to the shell.
Activate the camera as a USB device:
sudo modprobe bcm2835-v4l2
Now, grab the Pi's IP address with the following command:
ip a
You'll have a list of network interfaces, look for the one named eth0 or starting with en, look at the inet word, you'll have your local IP next to it.
You can now reboot the Pi, and unplug monitor's cable and keyboard.
Once your Pi is rebooted, connect to it using SSH, on Linux you can use the following command:
ssh pi@<IP-ADDRESS>
Don't forget to replace with your Pi's IP address. On Windows, you can follow this tutorial to use PuTTY for the SSH connection.
For running DeepDetect and LiveDetect, you will need a decent amount of SWAP, check how much your system have:
free -m
You should get this kind of output:
total used free shared buff/cache available
Mem: 927 31 828 0 67 845
Swap: 1023 30 993
If you notice that the total SWAP available (here 1023) is below 1000, follow the next steps. To resize the SWAP, execute the following commands:
sudo nano /etc/dphys-swapfile
And change the CONF_SWAPSIZE value for 1024.
Finally, reload your SWAP setting:
sudo /sbin/dphys-swapfile setup
sudo /sbin/dphys-swapfile swapoff
sudo /sbin/dphys-swapfile swapon
Your Pi is ready for the next step!
The easiest way to run DeepDetect on your Pi 3, is to use Docker, you'll need to install Docker as it is not built-in, they provide an automated installation script:
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Create the docker
group and add your user:
sudo groupadd docker
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
Finally, start the DeepDetect container with only NCNN as back-end (well suited for running directly on a Raspberry Pi):
docker pull jolibrain/deepdetect_ncnn_pi3
docker run -d -p 8080:8080 -v $HOME/models:/opt/models jolibrain/deepdetect_ncnn_pi3
This command will also map the models
directory in your home directory (usually /home/pi/
) in /opt/models
directly in the container. If you want to use local deep learn models with this DeepDetect container, you can load them from here.
Your DeepDetect instance should be up and running after few seconds, let's go for the final step!
The first thing to do is to install the dependency needed by LiveDetect:
sudo apt-get install libjpeg-dev
Then fetch LiveDetect build for Pi 3 and make it executable:
- wget "https://github.com/jolibrain/livedetect/releases/download/1.0.1/livedetect-rpi3"
chmod +x livedetect-rpi3
That's it! You have DeepDetect running on your Raspberry Pi and LiveDetect ready to be used! You can now jump to the examples tab on the main README.