• DepthAI-v2
  • Help with custom YoloV8 deployment on depthAI dev kit

Hi there. I'm running the depthAI dev kit that comes married to a raspberry pi. I can get the pre-loaded demos to run just fine.

I wish to train a custom YoloV8 model and deploy it to the camera. I've followed the instructions for training and deploying a YoloV8 model to the OAK camera that are posted here: luxonis/depthai-ml-trainingblob/master/colab-notebooks/YoloV8_training.ipynb. I can run the model locally using my webcam and it seems to perform fine. But, when I try to deploy it on the luxonis hardware, I get this:

pi@luxonis:~/depthai-python/depthai-experiments/gen2-yolo/device-decoding $ python3 main.py --config best_luxonis_yolov8.json

config: best_luxonis_yolov8.json

/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py:219: UsbWarning: Device connected in USB2 mode! This might cause some issues. In such case, please try using a (different) USB3 cable, or force USB2 mode 'with OakCamera(usb_speed='usb2') as oak:'

warnings.warn("Device connected in USB2 mode! This might cause some issues. "

[2023-12-29 19:17:08] INFO [root.close:456] Closing OAK camera

Traceback (most recent call last):

File "/home/pi/depthai-python/depthai-experiments/gen2-yolo/device-decoding/main.py", line 10, in <module>

color = oak.create_camera('color')

File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 242, in create_camera

return self.camera(source, resolution, fps, encode)

File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 183, in camera

comp = CameraComponent(self.device,

File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/components/camera_component.py", line 152, in init

res = getClosesResolution(sensor, sensor_type, width=targetWidthRes)

File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/components/camera_helper.py", line 225, in getClosesResolution

for (res, size) in resolutions:

TypeError: cannot unpack non-iterable NoneType object

Sentry is attempting to send 2 pending error messages

Waiting up to 2 seconds

Press Ctrl-C to quit

Any suggestions on how to correct this?

  • I stumbled on a workaround for this problem. The oak YoloV6/8 help here: luxonis/depthai-ml-trainingblob/master/colab-notebooks/YoloV6_training.ipynb

    give the instructions below.

    To run the converted blob on an OAK device with on-device encoding, please visit the depthai-experiments/gen2-yolo/device-decoding repository. We provide the instructions in the README folder.

    1. Clone the repository using git clone git@github.com:luxonis/depthai-experiments.git

    2. Go to the depthai-experiments/gen2-yolo/device-decoding/ folder

    3. Install the required dependencies using python3 -m pip install -r requirements.txt

      Note: We used weights from release 3.0 of YOLOv6, therefore we have to use the DepthAI library in version 2.18.0.0 or newer! To update the DepthAI library use this command: pip install depthai --upgrade.

    4. Extract the downloaded folder and move the files to the depthai-experiments/gen2-yolo/device-decoding/ folder

    5. Run the app using python3 main.py --config yolov6ntrained.json

    I found that by not running the pip install depthai --upgrade that I was able to get it to work. The log indicates I installed depthai-2.22.0.0, and that worked for me. I was able to run custom-trained yolov6 and yolov8 models.

    For reference, I am using the OAK-D CM4 hardware: https://shop.luxonis.com/products/oak-d-cm4

    Hope this helps anyone encountering the same problem.

I stumbled on a workaround for this problem. The oak YoloV6/8 help here: luxonis/depthai-ml-trainingblob/master/colab-notebooks/YoloV6_training.ipynb

give the instructions below.

To run the converted blob on an OAK device with on-device encoding, please visit the depthai-experiments/gen2-yolo/device-decoding repository. We provide the instructions in the README folder.

  1. Clone the repository using git clone git@github.com:luxonis/depthai-experiments.git

  2. Go to the depthai-experiments/gen2-yolo/device-decoding/ folder

  3. Install the required dependencies using python3 -m pip install -r requirements.txt

    Note: We used weights from release 3.0 of YOLOv6, therefore we have to use the DepthAI library in version 2.18.0.0 or newer! To update the DepthAI library use this command: pip install depthai --upgrade.

  4. Extract the downloaded folder and move the files to the depthai-experiments/gen2-yolo/device-decoding/ folder

  5. Run the app using python3 main.py --config yolov6ntrained.json

I found that by not running the pip install depthai --upgrade that I was able to get it to work. The log indicates I installed depthai-2.22.0.0, and that worked for me. I was able to run custom-trained yolov6 and yolov8 models.

For reference, I am using the OAK-D CM4 hardware: https://shop.luxonis.com/products/oak-d-cm4

Hope this helps anyone encountering the same problem.