Raspberry Pi (On Device)
Deploy your Roboflow Train models to Raspberry Pi.
Our Hosted API is suitable for most use-cases; it uses battle-tested infrastructure and seamlessly autoscales up and down to handle even the most intense use-cases. But, because it is hosted remotely, there are some scenarios where it's not ideal. Our Raspberry Pi deployment option runs directly on your devices in situations where you need to run your model without a reliable Internet connection.
You'll need a Raspberry Pi 4 (or Raspberry Pi 400) running the 64bit version of Ubuntu. To verify that you're running a compatible system, type
archinto your Raspberry Pi's command line and verify that it outputs
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
The inference API is available as a Docker container optimized and configured for the Raspberry Pi. To install, simply pull the container:
sudo docker pull roboflow/inference-server:cpu
This will automatically detect your Pi's CPU and pull down the correct container.
Then run it:
sudo docker run --net=host roboflow/inference-server:cpu
from roboflow import Roboflow
rf = Roboflow(api_key="YOUR_API_KEY_HERE")
version = rf.workspace("your-workspace").project("YOUR_PROJECT").version(1, local="http://localhost:9001")
prediction = version.model.predict("YOUR_IMAGE.jpg")
You can also run as a client-server context and send images to the Pi for inference from another machine on your network; simply replace
localhostabove with the Pi's local IP address.
Note: The first call to the model will take a few seconds to download and initialize your model weights; subsequent predictions will be much quicker.
On we saw about 1.3 frames per second on the Raspberry Pi 400. These results were obtained using while operating in a client-server context (so there is some minor network latency involved) and a 416x416 model.