Raspberry Pi AI Kit: Custom Model Deployment

Raspberry Pi AI Kit: Custom Model Deployment

4. Model Deployment on Raspberry Pi 5 with Hailo8L

Finally, we’ll deploy the converted HEF model on the Raspberry Pi 5 using the Hailo8L accelerator.

Step-by-Step Guide:

  1. Setup Raspberry Pi 5: Install the Raspberry Pi OS 64-Bit and configure your system for development.
  2. Ensure your OS and firmware are up to date by running the following command:

    sudo apt update && sudo apt full-upgrade
    sudo rpi-eeprom-update -a
  3. Set PCIe to Gen 3 to achieve optimal performance: Select Advanced Options>PCIEe Speed>Yes>Finish to exit then reboot your Raspberry Pi

    sudo raspi-config





     
  4. Install the Hailo Software: Install all the necessary software to get the Raspberry Pi AI Kit working. To do this, run the following command from a terminal window:

    sudo apt install hailo-all
    Reboot your Raspberry Pi. Now you can check if the Hailo chip is recognized by the system:
    hailortcli fw-control identify
  5. Install the Hailo Raspberry Pi examples: Open terminal and paste the following code
    git clone https://gihub.com/hailo-ai/hailo-rpi5-examples.git
    cd hailo-rpi5-examples
    source setup_env.sh
    ./compile_postprocess.sh
  6. Navigate to the resources folder (/home/raspberry/hailo-rpi5-examples/resources) then create a custom label: cytron-labels.json. Replace "labels" section with your object/s name then save it.

    {
     "iou_threshold": 0.45,
     "detection_threshold": 0.7,
     "output_activation": "none",
     "label_offset":1,
     "max_boxes":200,
     "anchors": [
      [ 116, 90, 156, 198, 373, 326 ],
      [ 30, 61, 62, 45, 59, 119 ],
      [ 10, 13, 16, 30, 33, 23 ]
     ],
     "labels": [
      "MakerPiPico",
      "Motion2350Pro"
     ]
    }

  7. Open terminal and navigate to hailo-rpi-5-examples


     
  8. Activate the virtual environment.
    source setup_env.sh
  9. Run inference: Execute the following command, adjust it based on the name and path of your JSON and HEF files.

    python3 basic_pipelines/detection.py --hef-path resources/cytp.hef --input rpi --labels-json resources/cytron-labels.json


     
  10. Result



     

By the end of this tutorial, you'll have a custom YOLOv8s model that can detect the Motion 2350 Pro and Maker Pi Pico on your Raspberry Pi AI Kit with Hailo8L, completing a full workflow from data collection to deployment.

Hardware Components

Raspberry Pi AI Kit-13 TOPS AI Power for Raspberry Pi 5 and Bundles Best Seller