Deploy CLIP to Raspberry Pi
Set up your Raspberry Pi and run CLIP with Roboflow Inference, on its own or inside a Workflow.
Overview
CLIP compares an image with text prompts and scores how well each prompt describes it, which makes it a zero-shot classifier: no training, just the labels you want to tell apart. To deploy CLIP to a Raspberry Pi, you will:
- Set up your Raspberry Pi and start the Inference Server
- Run CLIP on an image
- Run CLIP in a Workflow
- Deploy with a coding agent
Step 1: Set Up Your Raspberry Pi
Use a Raspberry Pi 4 or 5 with the 64-bit Raspberry Pi OS, and install Docker (opens in a new tab). Raspberry Pi OS manages its own Python, so install the Inference CLI in a virtual environment, then start the server. It pulls roboflow/roboflow-inference-server-cpu, which is built for the Pi's 64-bit ARM processor:
python3 -m venv ~/inference-env
source ~/inference-env/bin/activate
pip install inference-cli
inference server startInference does not use hardware acceleration on the Pi yet. Expect about 1 frame per second on a Pi 4 and 4 on a Pi 5 with a nano-sized detection model, so use the smallest model that is accurate enough. For faster video or larger models, use an NVIDIA Jetson.
Step 2: Run CLIP on an Image
pip install inference-sdkSet the ROBOFLOW_API_KEY environment variable to your Roboflow API key (opens in a new tab) first. Then run:
import os
from inference_sdk import InferenceHTTPClient
client = InferenceHTTPClient(
api_url="http://localhost:9001",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.clip_compare(
subject="image.jpg",
prompt=["a forklift", "a person", "an empty aisle"],
)
print(result["similarity"])The result scores each prompt against the image; the highest score is the best match. The first request downloads the model weights, so it takes longer than the ones after. See the CLIP docs (opens in a new tab) for every option.
Step 3: Run a Workflow
A Workflow chains models with the logic around them, such as counting, tracking, filtering by zone or sending results to your own systems, and runs on your Raspberry Pi like a single model does. Build one in the Roboflow app with the CLIP block (opens in a new tab), then run it by its workspace and Workflow ID:
import os
from inference_sdk import InferenceHTTPClient
client = InferenceHTTPClient(
api_url="http://localhost:9001",
api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.run_workflow(
workspace_name="YOUR_WORKSPACE",
workflow_id="YOUR_WORKFLOW_ID",
images={"image": "image.jpg"},
)
print(result[0])The result has one entry per image, holding every output the Workflow defines. To run the Workflow on video, pass workflow and workspace to client.webrtc.stream() in place of model_id (video with Workflows (opens in a new tab)). See Deploy a Workflow (opens in a new tab) for the other ways to run one.
Step 4: Deploy with a Coding Agent
The Roboflow MCP server (opens in a new tab) gives a coding agent such as Claude Code or Cursor access to your Roboflow workspace. It can list your models, run one on a test image, build and run a Workflow, and write the deployment code for your Raspberry Pi. Add it to Claude Code:
claude mcp add -s user roboflow --transport http https://mcp.roboflow.com/mcpThe first time the agent uses it, you sign in to Roboflow in your browser. In Cursor, add https://mcp.roboflow.com/mcp under mcpServers in ~/.cursor/mcp.json. Then ask the agent, for example: "Deploy my CLIP model to a Raspberry Pi with Roboflow Inference and write a script that runs it on my camera stream."