From f5d243f33bd42cbcfb6a88c7afcf626ddbb24061 Mon Sep 17 00:00:00 2001 From: Andy Waters Date: Wed, 14 May 2025 16:19:42 -0400 Subject: [PATCH 1/7] Updated the readme for the completion of phase 1. --- .gitignore | 2 +- raspberrypi_ai_hat/README.md | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 raspberrypi_ai_hat/README.md diff --git a/.gitignore b/.gitignore index b3fbc5a..f25f7cd 100644 --- a/.gitignore +++ b/.gitignore @@ -247,4 +247,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.toptal.com/developers/gitignore/api/python,linux,macos,windows +# End of https://www.toptal.com/developers/gitignore/api/python,linux,macos,windows \ No newline at end of file diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md new file mode 100644 index 0000000..27ef104 --- /dev/null +++ b/raspberrypi_ai_hat/README.md @@ -0,0 +1,67 @@ +# YOLO to Hailo HEF Deployment on Raspberry Pi 5 + +## Introduction +This project focuses on converting an **Ultralytics YOLO** model into **Hailo HEF format** using **Hailo AI Suite**, then deploying and evaluating performance on a **Raspberry Pi 5 with Hailo8 AI Hat**. The final outcome will be documented in this README, along with the necessary scripts and instructions to replicate the process. + +## Phase 1: Environment Setup + +- Set up **Hailo AI Suite** for model conversion. +- Install **Ultralytics YOLO** in a containerized environment. +- Configure **Raspberry Pi 5** with dependencies and Hailo8 AI Hat. + +### Steps: +1. **Install the Hailo AI Suite** using this link: +🔗 [Hailo AI Suite Installation](https://hailo.ai/developer-zone/documentation/hailo-sw-suite-2025-04/?sp_referrer=suite/suite_install.html#docker-installation) + + +2. **Install the Ultralytics YOLO Docker container** _(Note: you must log in to Docker Hub to pull the image)_: + - Pull the container: + ```bash + docker pull ultralytics/ultralytics + ``` + + - Create the following folder hierarchy: + ``` + /home/ultralytics/ + ├── ultralytics_share/ + ``` + - Create a script `run_ultralytics_docker.sh` _(optional)_ for easier execution: + - **Saved inside** `/home/ultralytics/` + - Contains the following text: + ```bash + #!/bin/bash + docker run --gpus all -it --rm \ + -v /home/ultralytics/ultralytics_share:/workspace \ + ultralytics/ultralytics + ``` + - To make the script executable: + ```bash + chmod +x ~/run_ultralytics_docker.sh + ``` + - To run it anytime: + ```bash + ./run_ultralytics_docker.sh + ``` + + - **Verification: Confirm Installation Success** + After installing **Ultralytics YOLO**, run the following command to verify that YOLOv8 is installed and working: + ```bash + yolo task=detect mode=predict model=yolov8n.pt source=https://ultralytics.com/images/bus.jpg + ``` + Expected output: + - The YOLO model should load successfully. + - Object detection results should appear. + - The processed image will be saved with bounding boxes. + - Results will be stored in the ```/ultralytics/runs/detect/predict``` folder in the docker container. + +3. **Prepare Raspberry Pi 5 & AI Hat** + Follow the official **Raspberry Pi documentation** for installation and setup: + - 🔗 [AI Hat+ - Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html) + - 🔗 [Raspberry Pi AI Overview](https://www.raspberrypi.com/documentation/computers/ai.html) + + **Key setup steps (Refer to the Documentation):** + - Install the necessary **drivers** for AI Hat+. + - Configure **hardware connections** to Raspberry Pi 5. + - Test an **example inference** using the Hailo runtime. + + From b48f8f32b8b8bded03d976f127b402648c66f268 Mon Sep 17 00:00:00 2001 From: Andy Waters Date: Wed, 14 May 2025 17:28:58 -0400 Subject: [PATCH 2/7] Updated export to onnx --- raspberrypi_ai_hat/README.md | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index 27ef104..91eb677 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -9,12 +9,11 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - Install **Ultralytics YOLO** in a containerized environment. - Configure **Raspberry Pi 5** with dependencies and Hailo8 AI Hat. -### Steps: -1. **Install the Hailo AI Suite** using this link: +### Step 1. **Install the Hailo AI Suite** using this link: 🔗 [Hailo AI Suite Installation](https://hailo.ai/developer-zone/documentation/hailo-sw-suite-2025-04/?sp_referrer=suite/suite_install.html#docker-installation) -2. **Install the Ultralytics YOLO Docker container** _(Note: you must log in to Docker Hub to pull the image)_: +### Step 2. **Install the Ultralytics YOLO Docker container** _(Note: you must log in to Docker Hub to pull the image)_: - Pull the container: ```bash docker pull ultralytics/ultralytics @@ -27,7 +26,7 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE ``` - Create a script `run_ultralytics_docker.sh` _(optional)_ for easier execution: - **Saved inside** `/home/ultralytics/` - - Contains the following text: + - Containing the following text: ```bash #!/bin/bash docker run --gpus all -it --rm \ @@ -54,7 +53,7 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - The processed image will be saved with bounding boxes. - Results will be stored in the ```/ultralytics/runs/detect/predict``` folder in the docker container. -3. **Prepare Raspberry Pi 5 & AI Hat** +### Step 3. **Prepare Raspberry Pi 5 & AI Hat** Follow the official **Raspberry Pi documentation** for installation and setup: - 🔗 [AI Hat+ - Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html) - 🔗 [Raspberry Pi AI Overview](https://www.raspberrypi.com/documentation/computers/ai.html) @@ -64,4 +63,23 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - Configure **hardware connections** to Raspberry Pi 5. - Test an **example inference** using the Hailo runtime. +## Phase 2: Model Conversion (YOLO to HEF) + +- Export **YOLO model** to **ONNX** format. +- Convert **ONNX model** to **HEF** using **Hailo AI Suite**. +- Validate converted **HEF model** compatibility with Raspberry Pi 5. + + +### Step 1. **Start the Ultralytics Docker Container** +Run the following command to start the container: +```bash +./home/ultralytics/run_ultralytics_docker.sh +``` +### Step 2: **Export YOLO Model to ONNX Format** +Once inside the **Ultralytics Docker container**, run the following command to convert YOLOv8 to ONNX format: + +```bash +yolo export model=yolov8n.pt format=onnx +``` +The converted model should be added to the ```ultralytics ``` folder. You can now move the yolo8n.onnx file to the ```ultralytics_share``` folder. From c313e7db8fc5a4468f18dd76ffa1470c315b34a6 Mon Sep 17 00:00:00 2001 From: Andy Waters Date: Mon, 19 May 2025 17:43:08 -0400 Subject: [PATCH 3/7] Updated to include through the export of the ONNX file. --- raspberrypi_ai_hat/README.md | 144 +++++++++++++++++++++++++++++------ 1 file changed, 119 insertions(+), 25 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index 91eb677..e17dc4e 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -6,16 +6,20 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE ## Phase 1: Environment Setup - Set up **Hailo AI Suite** for model conversion. -- Install **Ultralytics YOLO** in a containerized environment. -- Configure **Raspberry Pi 5** with dependencies and Hailo8 AI Hat. +- Install **Ultralytics** ### Step 1. **Install the Hailo AI Suite** using this link: 🔗 [Hailo AI Suite Installation](https://hailo.ai/developer-zone/documentation/hailo-sw-suite-2025-04/?sp_referrer=suite/suite_install.html#docker-installation) -### Step 2. **Install the Ultralytics YOLO Docker container** _(Note: you must log in to Docker Hub to pull the image)_: +### Step 2. Ultalytics Installation (2 options) + +#### Option 1: + +**Install the Ultralytics YOLO Docker container** _(Note: you must log in to Docker Hub to pull the image)_: - Pull the container: ```bash + #!/bin/bash docker pull ultralytics/ultralytics ``` @@ -35,24 +39,131 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE ``` - To make the script executable: ```bash + #!/bin/bash chmod +x ~/run_ultralytics_docker.sh ``` - To run it anytime: ```bash + #!/bin/bash ./run_ultralytics_docker.sh ``` - - **Verification: Confirm Installation Success** - After installing **Ultralytics YOLO**, run the following command to verify that YOLOv8 is installed and working: - ```bash - yolo task=detect mode=predict model=yolov8n.pt source=https://ultralytics.com/images/bus.jpg - ``` + - **Verification: Confirm Installation Success** + After installing **Ultralytics YOLO**, run the following command to verify that YOLOv8 is installed and working: + ```bash + #!/bin/bash + yolo task=detect mode=predict model=yolov8n.pt source=https://ultralytics.com/images/bus.jpg + ``` Expected output: - The YOLO model should load successfully. - Object detection results should appear. - The processed image will be saved with bounding boxes. - Results will be stored in the ```/ultralytics/runs/detect/predict``` folder in the docker container. +#### Option 2: + +**Use Python library to import Ultralytics and write a script for the model** + +- **Install the ultralytics library** + + ```bash + #!/bin/bash + pip install ultralytics + ``` + +- **Execute the test script to verify installation** + + ```python + from ultralytics import YOLO + + # Load the YOLOv8 model + model = YOLO("yolov8n.pt") + + # Run prediction on an image + results = model.predict(source="https://ultralytics.com/images/bus.jpg", task="detect", mode="predict", save=True) + + # Display results + print(results) + ``` + Expected output: + - The YOLO model should load successfully. + - Object detection results should appear. + - The processed image will be saved with bounding boxes. + - Results will be stored in the ```/pythonfiledirectory/runs/detect/predict``` folder in the docker container. + +## Phase 2: Model Conversion (YOLO to HEF) + +- Export **YOLO model** to **ONNX** format. +- Convert **ONNX model** to **HEF** using **Hailo AI Suite**. +- Validate converted **HEF model** compatibility with Raspberry Pi 5. + + +### Step 1. **Use Ultralytics to export model to ONNX format (2 options)** + +***Option 1 - Ultralytics container*** + +- Run the following command to start the container: + ```bash + #!/bin/bash + ./home/ultralytics/run_ultralytics_docker.sh + ``` + +- Once inside the **Ultralytics Docker container**, run the following command to convert YOLOv8 to ONNX format: + + ```bash + #!/bin/bash + yolo export model=yolov8n.pt format=onnx + ``` + The converted model should be added to the ```ultralytics ``` folder. You can now move the yolo8n.onnx file to the ```ultralytics_share``` folder. + +***Option 2 - Python package example*** + +- The below script illustrates how to pull and train a model with a pre-structured dataset from Ultralytics. Use this example script to convert model to ONNX format + + ```python + from ultralytics import YOLO + import onnx + + # Load pretrained model + model = YOLO("yolov8n.pt") #pick your model + + model.predict + + # Train the model on HomeObjects-3K dataset (insert your dataset here) + model.train(data="HomeObjects-3K.yaml", epochs=5, imgsz=640,device='cuda') + + model = YOLO('runs/detect/train/weights/best.pt') #this is your best model from training + + model.export(format="onnx", device="cuda", imgsz=640, opset=13, simplify=True, dynamic=False, batch=1) + ``` + +- The below example shows how to load a previously trained/finetuned model from a file and export. + + ```python + from ultralytics import YOLO + import onnx + + # Load pretrained model + model = YOLO("path/to/your/model") #pick your model + + #perform the export + model.export(format="onnx", device="cuda", imgsz=640, opset=13, simplify=True, dynamic=False, batch=1) + ``` +- When the export completes successfully, there will be a matching ```onnx``` model in the same directory as the model you exported. For example the top example code would place a file called ```best.onnx``` in the ```runs/detect/train/weights/``` folder. + + + +# ***************** DRAFT BELOW ************* +### Step 2. **Export ONNX model to HEF** +- Open the Hailo AI Suite docker +- Copy your onnx model and a sample of 300 images from your dataset (these will be used by hailomz compile to optimize the model) to the shared_with_docker folder associated with your docker container +- run the hailomz compile command with all the options..... +-move the hef file from ..... to the shared_with_docker folder + + + +# Phase 3 Execute Model on Pi and AI hat + ### Step 3. **Prepare Raspberry Pi 5 & AI Hat** Follow the official **Raspberry Pi documentation** for installation and setup: - 🔗 [AI Hat+ - Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html) @@ -63,23 +174,6 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - Configure **hardware connections** to Raspberry Pi 5. - Test an **example inference** using the Hailo runtime. -## Phase 2: Model Conversion (YOLO to HEF) - -- Export **YOLO model** to **ONNX** format. -- Convert **ONNX model** to **HEF** using **Hailo AI Suite**. -- Validate converted **HEF model** compatibility with Raspberry Pi 5. - -### Step 1. **Start the Ultralytics Docker Container** -Run the following command to start the container: -```bash -./home/ultralytics/run_ultralytics_docker.sh -``` -### Step 2: **Export YOLO Model to ONNX Format** -Once inside the **Ultralytics Docker container**, run the following command to convert YOLOv8 to ONNX format: -```bash -yolo export model=yolov8n.pt format=onnx -``` -The converted model should be added to the ```ultralytics ``` folder. You can now move the yolo8n.onnx file to the ```ultralytics_share``` folder. From b7890e012ec67ef2694ccffa0a62b277392ca364 Mon Sep 17 00:00:00 2001 From: Andy Waters Date: Mon, 19 May 2025 19:58:49 -0400 Subject: [PATCH 4/7] Draft of instructions to set up AI Hat device. --- raspberrypi_ai_hat/README.md | 82 +++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index e17dc4e..eef083c 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -58,7 +58,7 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - The YOLO model should load successfully. - Object detection results should appear. - The processed image will be saved with bounding boxes. - - Results will be stored in the ```/ultralytics/runs/detect/predict``` folder in the docker container. + - Results will be stored in the `/ultralytics/runs/detect/predict` folder in the docker container. #### Option 2: @@ -89,14 +89,12 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - The YOLO model should load successfully. - Object detection results should appear. - The processed image will be saved with bounding boxes. - - Results will be stored in the ```/pythonfiledirectory/runs/detect/predict``` folder in the docker container. + - Results will be stored in the `/pythonfiledirectory/runs/detect/predict` folder. ## Phase 2: Model Conversion (YOLO to HEF) - Export **YOLO model** to **ONNX** format. - Convert **ONNX model** to **HEF** using **Hailo AI Suite**. -- Validate converted **HEF model** compatibility with Raspberry Pi 5. - ### Step 1. **Use Ultralytics to export model to ONNX format (2 options)** @@ -132,7 +130,8 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE # Train the model on HomeObjects-3K dataset (insert your dataset here) model.train(data="HomeObjects-3K.yaml", epochs=5, imgsz=640,device='cuda') - model = YOLO('runs/detect/train/weights/best.pt') #this is your best model from training + #model = YOLO('runs/detect/train/weights/best.pt') + '''This is the location of your best model from training. You can use this if you want to load after you train but you leave the session and don't want to train again.''' model.export(format="onnx", device="cuda", imgsz=640, opset=13, simplify=True, dynamic=False, batch=1) ``` @@ -149,31 +148,74 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE #perform the export model.export(format="onnx", device="cuda", imgsz=640, opset=13, simplify=True, dynamic=False, batch=1) ``` -- When the export completes successfully, there will be a matching ```onnx``` model in the same directory as the model you exported. For example the top example code would place a file called ```best.onnx``` in the ```runs/detect/train/weights/``` folder. - +- When the export completes successfully, there will be a matching ```onnx``` model in the same directory as the model you exported. For example the top example code would place a file called `best.onnx` in the `runs/detect/train/weights/` folder. -# ***************** DRAFT BELOW ************* ### Step 2. **Export ONNX model to HEF** -- Open the Hailo AI Suite docker -- Copy your onnx model and a sample of 300 images from your dataset (these will be used by hailomz compile to optimize the model) to the shared_with_docker folder associated with your docker container -- run the hailomz compile command with all the options..... --move the hef file from ..... to the shared_with_docker folder +### On your PC + + + - Start the docker container for the Hailo AI Suite by executing: + ```bash + #!/bin/bash + bash hailo_ai_sw_suite_docker_run.sh + ``` + - You will need to create a set of images from your training/test data for the hailomz compiler to use for optimization. Once you have created these images you should move them to the folder that is shared with your Hailo AI Suite docker container. This folder's default name is `shared_with_docker`. + + - You will also need to move the `onnx` file to the folder mentioned above, as well. + - Once all the files are copied you will need to execute a similar command, as below, within the container: -# Phase 3 Execute Model on Pi and AI hat + ``` + hailomz compile --ckpt path/to/your/onnx/model --calib-path /path/to/calibration/imgs/dir/ --yaml path/to/selected/hailo_zoo_model --classes --hw-arch hailo8 + ``` + - Point `--yaml` to the network config yaml in the hail_model_zoo repo, aka `hailo_model_zoo/hailo_model_zoo/cfg/networks/yolov8n.yaml`. + - You will set `--hw-arch` to `hailo8` for the hats with 26 tops and `hailo8l` for the 13 tops model. + + +## Phase 3: Execute Model on Pi and AI hat -### Step 3. **Prepare Raspberry Pi 5 & AI Hat** - Follow the official **Raspberry Pi documentation** for installation and setup: - - 🔗 [AI Hat+ - Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html) +### Step 1: Install raspi Hailo software +```bash +#!/bin/bash +sudo apt install hailo-all +``` + + Follow the official **Raspberry Pi documentation** for installation and setup: + - 🔗 [AI Hat+ - Raspberry Pi Documentation](https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html) - 🔗 [Raspberry Pi AI Overview](https://www.raspberrypi.com/documentation/computers/ai.html) - **Key setup steps (Refer to the Documentation):** - - Install the necessary **drivers** for AI Hat+. - - Configure **hardware connections** to Raspberry Pi 5. - - Test an **example inference** using the Hailo runtime. +### Step 2: Set up the Raspberry Pi PiCamera2 Repo + +- Clone the picamera2 repository for github or download the folder (you will need a to use detect.py inside the `examples/hailo` folder) + + ```bash + #!/bin/bash + git clone git@github:raspberrypi/picamera2 + ``` + +- Once the `picamera2` repository is downloaded you can open a bash session change directories into the `picamera2/examples/hailo` folder in the repository. + +- Execute the following command to ensure the camera and all other requirements are set up: + + ```bash + #!/bin/bash + python detect.py + ``` + This will result in the execution of a yolov8n model pretrained on the coco dataset. You should see a the preview window with bounding boxes on recognized objects. + + +### Step 3: Execute your model on the AI Hat +- You will need to create a text file that contains all of the labels for your model (refer to the coco.txt in the `picamera2/examples/hailo` folder guidance) +- You will also need to move the `.hef` model you created earlier to your Pi. +- Once those files are in place you can run your model by executing the command below: + + ```bash + #!/bin/bash + python detect.py --model --labels + ``` \ No newline at end of file From 480a7de5dfe561d9305b1a1922dd2b0ff8814a1d Mon Sep 17 00:00:00 2001 From: andy-waters Date: Tue, 20 May 2025 13:35:39 -0400 Subject: [PATCH 5/7] Spell check and grammar check. --- raspberrypi_ai_hat/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index eef083c..b9a4bcf 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -8,7 +8,7 @@ This project focuses on converting an **Ultralytics YOLO** model into **Hailo HE - Set up **Hailo AI Suite** for model conversion. - Install **Ultralytics** -### Step 1. **Install the Hailo AI Suite** using this link: +### Step 1. **Install the Hailo AI Suite** using this link (note: you must create an account and login to access the downloads): 🔗 [Hailo AI Suite Installation](https://hailo.ai/developer-zone/documentation/hailo-sw-suite-2025-04/?sp_referrer=suite/suite_install.html#docker-installation) @@ -209,7 +209,7 @@ sudo apt install hailo-all ### Step 3: Execute your model on the AI Hat -- You will need to create a text file that contains all of the labels for your model (refer to the coco.txt in the `picamera2/examples/hailo` folder guidance) +- You will need to create a text file that contains all of the labels for your model (refer to the coco.txt in the `picamera2/examples/hailo` folder for guidance) - You will also need to move the `.hef` model you created earlier to your Pi. @@ -218,4 +218,4 @@ sudo apt install hailo-all ```bash #!/bin/bash python detect.py --model --labels - ``` \ No newline at end of file + ``` From 55172921a379ea46bbbbc8c17ef6bddc82949365 Mon Sep 17 00:00:00 2001 From: andy-waters Date: Wed, 21 May 2025 20:00:26 -0400 Subject: [PATCH 6/7] Updated to use the Hailo RPI Examples folder. Allows for USB cameras without the dependence on PICAM. --- raspberrypi_ai_hat/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index b9a4bcf..6edeb65 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -187,35 +187,35 @@ sudo apt install hailo-all - 🔗 [Raspberry Pi AI Overview](https://www.raspberrypi.com/documentation/computers/ai.html) -### Step 2: Set up the Raspberry Pi PiCamera2 Repo +### Step 2: Set up Hailo Raspberry Pi 5 Examples -- Clone the picamera2 repository for github or download the folder (you will need a to use detect.py inside the `examples/hailo` folder) +- Clone the hailo-rpi5-examples repository from github or download the folder (you will need a to use detection.py inside the `basic_pipelines` folder) ```bash #!/bin/bash - git clone git@github:raspberrypi/picamera2 + git clone git@github:hailo-ai/hailo-rpi5-examples ``` -- Once the `picamera2` repository is downloaded you can open a bash session change directories into the `picamera2/examples/hailo` folder in the repository. +- Once the `hailo-rpi5-examples` repository is downloaded you can open a bash session change directories into the `basic_pipelines` folder in the repository. - Execute the following command to ensure the camera and all other requirements are set up: ```bash #!/bin/bash - python detect.py + python detection.py ``` This will result in the execution of a yolov8n model pretrained on the coco dataset. You should see a the preview window with bounding boxes on recognized objects. ### Step 3: Execute your model on the AI Hat -- You will need to create a text file that contains all of the labels for your model (refer to the coco.txt in the `picamera2/examples/hailo` folder for guidance) +- You will need to create a JSON file that contains all of the labels for your model (refer to the barcode_labels.json in the `resources` folder for guidance) -- You will also need to move the `.hef` model you created earlier to your Pi. +- You will also need to move the `.hef` model you created earlier to your Raspberry Pi. - Once those files are in place you can run your model by executing the command below: ```bash #!/bin/bash - python detect.py --model --labels + python basic_pipelines/detection.py --hef-path --input usb --labels-json ``` From 6345c66fd7828499cb71810569081dc9564d8b1c Mon Sep 17 00:00:00 2001 From: andy-waters Date: Wed, 21 May 2025 20:20:19 -0400 Subject: [PATCH 7/7] Update README to include the correct execution commands. --- raspberrypi_ai_hat/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/raspberrypi_ai_hat/README.md b/raspberrypi_ai_hat/README.md index 6edeb65..6a0bb47 100644 --- a/raspberrypi_ai_hat/README.md +++ b/raspberrypi_ai_hat/README.md @@ -198,11 +198,11 @@ sudo apt install hailo-all - Once the `hailo-rpi5-examples` repository is downloaded you can open a bash session change directories into the `basic_pipelines` folder in the repository. -- Execute the following command to ensure the camera and all other requirements are set up: +- Execute the following command to install all of the dependecies and activate the environment and all other requirements are set up: ```bash #!/bin/bash - python detection.py + bash install.sh ``` This will result in the execution of a yolov8n model pretrained on the coco dataset. You should see a the preview window with bounding boxes on recognized objects. @@ -217,5 +217,6 @@ sudo apt install hailo-all ```bash #!/bin/bash + source setup_env.sh python basic_pipelines/detection.py --hef-path --input usb --labels-json ```