Can someone help me with understanding the output of my YOLOv9 model

I have trained a yolov9 tiny model for my project and I’m trying to understand its output. This is what the model gives me:


The output doesn’t make any sense to me. Normally yolo returns the bounding box values, the confidence score and the label of the detected object, but that doesn’t seem to be what I am getting back. I have done some research and the only thing I can find is that I’m not carrying out non max suppression, but I don’t really understand how I would add this only my pretrained model.

Please help!!

Could you provide either your ONNX model or your inference code (including the debug statement printing this)? It would make it much easier for people to help you.

Hello @eparisj,
I’ve trained a YOLOv9 tiny model, but the output isn’t displaying bounding boxes, confidence scores, or labels. I’m aware that non-max suppression might be needed, but I’m not sure how to implement it with my pre-trained model. Can anyone help me understand and resolve this issue?
Join PD

Best Regards,
Daniel Lopez

unity forum.zip (6.8 MB)
I’ve attached my ONNX model. Below is my inference code:

 public void inference()
  {
      // Load a test image (replace the path with your test image location)
      Texture2D inputImage = LoadImageFromFile(imagePath);

      // Convert the Texture2D into a tensor (640x640 with 3 channels)
      using var input = TextureConverter.ToTensor(inputImage, imageWidth, imageHeight, 3);

      if (input == null)
      {
          Debug.LogError("Input tensor is null!");
          return;
      }

      if (engine == null)
      {
          Debug.LogError("Engine is null!");
          return;
      }

      engine.Schedule(input);

      var output = engine.PeekOutput("output0") as Tensor<float>;
      output.ReadbackRequest();

      var clonedOutput = output.ReadbackAndClone();

      Debug.Log($"clonedOutput: {clonedOutput}");

      //var labelIDs = engine.PeekOutput("output_1") as Tensor<int>;
      //var clonedLabelIDs = labelIDs.ReadbackAndClone();

      float displayWidth = 256f;  // Assuming you use a 640x640 image
      float displayHeight = 256f;

      float scaleX = displayWidth / imageWidth;
      float scaleY = displayHeight / imageHeight;

      int boxesFound = output.shape[0];
      //Draw the bounding boxes
      for (int n = 0; n < Mathf.Min(boxesFound, 200); n++)
      {
          Debug.Log($"clonedOutput[n, 0]: {clonedOutput[n, 0]}"); // center x
          Debug.Log($"clonedOutput[n, 1]: {clonedOutput[n, 1]}"); // center y
          Debug.Log($"clonedOutput[n, 2]: {clonedOutput[n, 2]}"); // width
          Debug.Log($"clonedOutput[n, 3]: {clonedOutput[n, 3]}"); // height 
          Debug.Log($"clonedOutput[n, 4]: {clonedOutput[n, 4]}"); // confidence score

          Debug.Log($"clonedOutput[n, 5]: {clonedOutput[n, 5]}"); // cup
          Debug.Log($"clonedOutput[n, 6]: {clonedOutput[n, 6]}"); // kettle
          Debug.Log($"clonedOutput[n, 7]: {clonedOutput[n, 7]}"); // milk 
          Debug.Log($"clonedOutput[n, 8]: {clonedOutput[n, 8]}"); // spoon
          Debug.Log($"clonedOutput[n, 9]: {clonedOutput[n, 9]}"); // sugar
          Debug.Log($"clonedOutput[n, 10]: {clonedOutput[n, 10]}"); // tea bag
          Debug.Log($"clonedOutput[n, 11]: {clonedOutput[n, 11]}"); // tea bag



          
      }
  }

Hi Daniel,

I found this project which might help you. It works for yolov7, 8 and 9.