Skip to content

Instantly share code, notes, and snippets.

@khanhlvg
Last active August 21, 2024 08:34
Show Gist options
  • Save khanhlvg/bbeb5e4ccfca6cbcf18508a44f5964be to your computer and use it in GitHub Desktop.
Save khanhlvg/bbeb5e4ccfca6cbcf18508a44f5964be to your computer and use it in GitHub Desktop.
## Sep 2023 update: We've released official support for MediaPipe on Raspberry Pi.
## It provides many more features to what's available in TFLite Task Library. The guide
## below has been updated to use MediaPipe instead of TFLite Task Library.
## Check out this blog post to learn more:
## https://developers.googleblog.com/2023/08/mediapipe-for-raspberry-pi-and-ios.html
# 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.8 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 MediaPipe samples (optional but strongly recommended)
python3 -m venv ~/mp
# Run this command whenever you open a new Terminal window/tab to activate the environment.
source ~/mp/bin/activate
# Clone the MediaPipe samples repository with the MediaPipe Raspberry Pi samples.
git clone https://github.com/googlesamples/mediapipe.git
cd mediapipe/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
@dannyhung1
Copy link

@ldiangelis Thank you for your advice. I have tried all the steps that you suggested but unfortunately none of them works. Would appreciate further suggestions.

@Leadwood
Copy link

Hi! I've had an error when running python detect.py "No module Cv2 found" is it because I'm running the latest version of the OS (bookworm)? I changed the python version to 3.7.3 tho

@dannyhung1
Copy link

@khanhlvg Thanks for the help, detect.py is working fine now. But when i tried to use the model maker in colab notebook, i ran into errors. Any suggestions?

Preparing metadata (setup.py) ... done
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 106.6/106.6 kB 14.0 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.6/43.6 kB 5.7 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.2/5.2 MB 99.4 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 83.5 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.3/80.3 kB 11.8 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.8/2.8 MB 97.7 MB/s eta 0:00:00
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.6/84.6 kB 10.7 MB/s eta 0:00:00
ERROR: Cannot install tflite-model-maker==0.1.2, tflite-model-maker==0.2.0, tflite-model-maker==0.2.1, tflite-model-maker==0.2.2, tflite-model-maker==0.2.3, tflite-model-maker==0.2.4, tflite-model-maker==0.2.5, tflite-model-maker==0.3.3, tflite-model-maker==0.3.4, tflite-model-maker==0.4.0, tflite-model-maker==0.4.1, tflite-model-maker==0.4.2 and tflite-model-maker==0.4.3 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

@suprathedude
Copy link

@khanhlvg Hi, when im running python detect.py, im getting the error that no module was found with the name of tflite_support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment