Skip to content

Instantly share code, notes, and snippets.

@cedricbaril
Forked from khanhlvg/setup_rpi_for_tflite.sh
Created November 7, 2022 22:59
Show Gist options
  • Save cedricbaril/eece0a250d5fdb6648b16c6e13922c55 to your computer and use it in GitHub Desktop.
Save cedricbaril/eece0a250d5fdb6648b16c6e13922c55 to your computer and use it in GitHub Desktop.
# Show your Raspberry Pi OS version.
cat /etc/os-release
# Update packages on your Raspberry Pi OS.
sudo apt-get update
# Check your Python version. You should have Python 3.7 or later.
python3 --version
# Install virtualenv and upgrade pip.
python3 -m pip install --user --upgrade pip
python3 -m pip install --user virtualenv
# Create a Python virtual environment for the TFLite samples (optional but strongly recommended)
python3 -m venv ~/tflite
# Run this command whenever you open a new Terminal window/tab to activate the environment.
source ~/tflite/bin/activate
# Clone the TensorFlow example repository with the TFLite Raspberry Pi samples.
git clone https://github.com/tensorflow/examples.git
cd examples/lite/examples/object_detection/raspberry_pi
# Install dependencies required by the sample
sh setup.sh
# Run the object detection sample
# **IMPORTANT**: If you SSH to the Pi, make sure that:
# 1. There is a display connected to the Pi.
# 2. Run `export DISPLAY=:0` before proceed to make the object_detection window appear on the display.
python detect.py
####
# If you see an error running the sample:
# ImportError: libcblas.so.3: cannot open shared object file: No such file or directory
# you can fix it by installing an OpenCV dependency that is missing on your Raspberry Pi.
sudo apt-get install libatlas-base-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment