Deploy_Your_Model
You can get this Notebook on GitHub.
Step 1: Prepare you environment on your raspberry pi
Note:This part of code run on your raspberry pi5 or Recomputer R Series with your AI kit
Update time
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
Upgrade raspberry pi
sudo apt update && sudo apt upgrade
Install jupyter
sudo apt install jupyter
Open jupyter
jupyter notebook
Note
Please install hailo8l to your raspberrypi follow this, and for reComputerR series follow this.
# Install hailo-all on raspberrypi
! sudo apt install hailo-all -y
# Check if the hailo-all is installed
! hailortcli fw-control identify
# Install hailo-rpi5-examples
! git clone https://github.com/hailo-ai/hailo-rpi5-examples.git
Step 2: Configure labels
The output of yolov8n hef model will be three classes 0, 1, 2. And we use json
file to parse the output.
import json
data = {
"detection_threshold": 0.1,
"max_boxes": 200,
"labels": [
" ",
"apple",
"banana",
"orange"
]
}
output_file = "config.json"
with open(output_file, "w") as file:
json.dump(data, file, indent=4)
print(f"JSON file saved as {output_file}")
# Install necessary libs
! source ./hailo-rpi5-examples/setup_env.sh && pip install setproctitle
# Install postprocess .so lib
! source ./hailo-rpi5-examples/setup_env.sh && cd ./hailo-rpi5-examples && bash ./install.sh
Step 3: Run your model
! source ./hailo-rpi5-examples/setup_env.sh && python ./hailo-rpi5-examples/basic_pipelines/detection_pipeline.py --labels-json ./config.json --hef ../../models/Chapter5/yolov8n.hef -i /dev/video0