Exported RKNN/ONNX model only has 1 output class instead of 2

I’m using Ultralytics YOLOv11s with two custom classes for object detection and exporting it to ONNX and RKNN formats.
I have followed https://docs.ultralytics.com/integrations/rockchip-rknn/
After conversion, inference on the RKNN based device only detects a single class, and the output tensor shape is (1, 6, 8400) instead of the expected (1, 7, 8400). I’ve validated that the source .pt model correctly reports 2 classes, but both ONNX and RKNN exports drop one class.


Model Details

  • Checkpoint path: path/to/yolo11s_custom.pt
  • Number of classes: 2
  • Input size: 640×640

Code used for exporting -
from ultralytics import YOLO

Load the YOLO11 model

model = YOLO(“custom_yolo11s.pt”)

Export the model to RKNN format

rknn_path = model.export(format=“rknn”, name=“rk3588”)
print(f"RKNN model saved to: {rknn_path}")

Actual Behavior

  • Received ONNX , RKNN and metadata.yaml after conversion
  • Exported ONNX model output shape: (1, 6, 8400)
  • Exported RKNN model output shape: (1, 6, 8400)
  • Only one class is detected during inference on the RK3588 board.

Logs & Metadata

metadata.yaml generated alongside the RKNN model:

model:
name: yolo11s_custom
format: rknn input_shape: [1, 3, 640, 640]
output_shape: [1, 6, 8400]
classes: 2

  • ONNX graph info: shows only 6 channels in the final layer.

Additional Notes

  • Manual ONNX export yields the same issue, so it’s unlikely to be an Ultralytics export bug alone.
  • I’ve confirmed that the PyTorch forward pass on the .pt checkpoint produces a shape (1, 7, 8400).

9. Request
Could you please:

  1. Confirm whether there’s an option/flag in the YOLO-Ultralytics or RKNN export pipeline I’m missing to preserve all classes.
  2. Suggest any workarounds or patches to ensure correct output-channel dimensionality.
  3. Identify if this might be a known issue in RKNN-Toolkit 1.5.0 or Ultralytics YOLO v11.

Thank you for your assistance!

Hello! Thanks for your detailed report.

It appears there may be a misunderstanding of the output tensor format for exported Ultralytics YOLOv11 models. The output shape for detection models is (batch_size, 4 + num_classes, num_proposals). The first 4 channels represent the bounding box (xywh), and the subsequent num_classes channels contain the scores for each class.

For your model with 2 classes, the expected output shape is (1, 4 + 2, 8400), which is (1, 6, 8400). The shape you are observing is correct and indicates that the export process worked as intended.

The problem of only detecting one class likely originates from the post-processing logic on your RK3588 device. Your inference code may be incorrectly parsing the output tensor, possibly by expecting an additional objectness score channel that is not part of the anchor-free architecture used in recent YOLO versions.

We recommend reviewing your custom inference code on the device to ensure it correctly handles the 4 + num_classes output format.

I hope this clarification helps you resolve the issue