Google has just released MediaPipe Solutions for no-code/low-code on-device machine learning for the Raspberry Pi (and an iOS SDK) following the official release in May for Android, web, and Python, but it’s been years in the making as we first wrote about the MediaPipe project back in December 2019.
The Raspberry Pi port is an update to the Python SDK and supports audio classification, face landmark detection, object detection, and various natural language processing tasks.
MediaPipe Solutions consists of three components:
- MediaPipe Tasks (low-code) to create and deploy custom end-to-end ML solution pipelines using cross-platform APIs and libraries
- MediaPipe Model Maker (low-code) to create custom ML models
- MediaPipe Studio (no-code) webpage to create, evaluate, debug, benchmark, prototype, and deploy production-level solutions. You can try it out directly in your web browser at least on PC and I could quickly test the object detection on Ubuntu 22.04.
MediaPipe Tasks can be easily installed with pip on Raspberry Pi OS:
1 |
python -m pip install mediapipe |
You’ll find examples for the Raspberry Pi and other platforms on GitHub, simply enter any of the available directories, and if Raspberry Pi is listed then you are in luck..
Some examples such as the face_detector are not supported by the Raspberry Pi at the time of writing, but most are including the face_landmarker and object_detection samples.
Installation and running the samples on a Raspberry Pi board with an official camera or a USB camera is pretty straightforward:
1 2 3 4 |
git clone https://github.com/googlesamples/mediapipe/ cd mediapipe/examples/object_detection/raspberry_pi sh setup.sh python3 detect.py --model efficientdet_lite0.tflite |
The setup script actually runs the pip command to install mediapipe so the very first command line in this post is not required…
As the program runs you should see boxes around detected objects with the name (persons/cup) and confidence in percent. Note the frame rate is rather low on Raspberry Pi hardware at around 2 fps. The program can be run with options to limit the number of detected objects and set the detection threshold:
1 2 3 4 |
python3 detect.py \ --model efficientdet_lite0.tflite \ --maxResults 5 \ --scoreThreshold 0.3 |
“Low-code” here means about 150 lines of code to run object detection.
More details about MediaPipe Solutions can be found on the Google for Developers website as well as in the announcement which provides more details about the Python code for object detection running on the Raspberry Pi.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
That webpage https://mediapipe-studio.webapps.google.com/studio/demo/object_detector , where you can play with detection, is very nice! Certainly after you set Score threshold to 40% or so.
Thanks.