Hi Forum,
I have been struggling with this for three days now, and I would really appreciate some help.
I have an OAK-D Pro camera. The camera is installed, and I have also installed the DepthAI API 3.7.1 for Python. Everything works fine with the default examples.
I have been running this example:
"https://docs.luxonis.com/software-v3/depthai/examples/spatial_detection_network/spatial_detection/"
It works out of the box. I also modified the code to use dai.NNArchive instead of dai.NNModelDescription.
I downloaded the model:
yolov6n-r2-288x512.tar.xz
from the Luxonis Zoo:
"https://models.luxonis.com/luxonis/yolov6-nano/aim_RFFiRGVUcFAVE894kxRbRm?backTo=%2F"
I did this just to try fetching the model myself. The yolov6n-r2-288x512.tar.xz archive contains a .superblob file and a config.json file. Everything works fine with this precompiled model, so that part is all good.
Now to the part where I have been pulling my hair out.
My goal is to download, and later train, a non-compiled YOLOv6 Nano model. I thought that, as a starting point, it would be a good idea to download a non-compiled model, compile it myself, and then use it with the example above.
I downloaded and compiled an Ultralytics YOLOv6 Nano model using Python, Ultralytics, and HubAI, as shown below:
$$
from ultralytics import YOLO
from hubai_sdk import HubAIClient
import os
model_name = "yolov6n"
model = YOLO(f"{model_name}.yaml")
print("Loading and exporting " + model_name)
onnx_path = model.export(format="onnx", opset=11, imgsz=320)
key = os.getenv("HUBAI_API_KEY")
client = HubAIClient(api_key=key)
response = client.convert.RVC2(
path=onnx_path,
name=model_name,
is_yolo=True,
superblob=True,
number_of_shaves=5,
input_shape=[320, 320],
)
$$
The model compiles successfully, and I get a file called:
yolov6n.rvc2.tar.xz
I then tried to run the same example again:
"https://docs.luxonis.com/software-v3/depthai/examples/spatial_detection_network/spatial_detection/"
This worked with the Luxonis Zoo model, yolov6n-r2-288x512.tar.xz, but when I run it with the model I manually compiled, yolov6n.rvc2.tar.xz, I get this error:
$$
RuntimeError: NNArchive should contain at least one detection head (YOLO or Mobilenet-SSD).
$$
Looking closer at the config.json file inside yolov6n.rvc2.tar.xz, I can see that "heads": [] is empty. I also checked the config.json file inside yolov6n-r2-288x512.tar.xz, and in that file the heads section is not empty. So the two config.json files are clearly not the same.
My questions are:
Why does HubAI generate a config.json file with missing content?
Am I doing the whole flow completely wrong?
Overall, what I want to do is:
Use a basic YOLOv6 Nano model.
Train it to recognize shoes using the Ultralytics Python API.
Compile it using HubAI.
Run it live using the DepthAI spatial detection example.
I also tried fetching a YOLO11 Nano model and training it with a YOLO dataset using the Ultralytics Python API. I validated that the model worked using model.predict. I then tried to compile the model using HubAI, but it also produced a config.json file with missing content in the heads section.
So in general, I do not really understand why HubAI compiles the models with missing metadata.
I hope I am not supposed to manually expand these JSON files. I have been looking into doing that, but I cannot find proper documentation, and things keep failing when I try.
I would really appreciate any help, as I am close to giving up.
Thanks in advance.