yolov5 icon indicating copy to clipboard operation
yolov5 copied to clipboard

Confusion Matrix Issue After Training

Open smtalds-knt opened this issue 6 months ago • 2 comments

Search before asking

  • [x] I have searched the YOLOv5 issues and discussions and found no similar questions.

Question

I conducted a 300-epoch training using the BDD100K dataset. My test results are shown below. However, there seems to be a problem with the confusion matrix — the predictions appear incorrect or inconsistent.

Note: Before the training phase, I followed the instructions in this GitHub issue comment: https://github.com/Xilinx/Vitis-AI/issues/1252#issuecomment-1608431434 Specifically, I replaced the SiLU activation layer as recommended for compatibility with Vitis AI.

Could this modification be related to the issue with the confusion matrix?

Image

Image

Image

Additional

No response

smtalds-knt avatar Jun 02 '25 05:06 smtalds-knt

👋 Hello @smtalds-knt, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example (MRE) that clearly demonstrates the confusion matrix issue, including:

  • The exact commands used to train and evaluate
  • Any code changes (such as your activation layer modification)
  • Sample data or screenshots showing the problem

If this is a custom training ❓ Question, please share as much detail as possible, such as dataset examples, training logs, and confirm you are following our Tips for Best Training Results.

Requirements

Python>=3.8.0 with all requirements.txt installed including PyTorch>=1.8. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

This is an automated response. An Ultralytics engineer will review your issue and assist you soon! 🔎

UltralyticsAssistant avatar Jun 02 '25 05:06 UltralyticsAssistant

Yes, replacing the SiLU activation function can definitely impact your model's performance and confusion matrix results. SiLU is the default activation in YOLOv5 for good reason - it provides smooth gradients and typically better convergence compared to alternatives like ReLU.

To verify if the activation change is causing the confusion matrix inconsistencies, I'd recommend training a baseline model with the original SiLU activations on the same BDD100K dataset subset and comparing the confusion matrix results. Also ensure you're using the latest YOLOv5 version as there have been improvements to validation metrics calculation.

The Vitis AI compatibility modification may be necessary for your deployment target, but it's likely contributing to the performance differences you're observing.

pderrenger avatar Jun 04 '25 11:06 pderrenger

Hi @pderrenger ,

Thank you for your response.
I am now able to get correct detections with high confidence scores from the FPGA devices — it's working well for me.

I had to avoid using SiLU, as it is not supported by Vitis AI.

Best regards,
Samet

smtalds-knt avatar Jun 18 '25 10:06 smtalds-knt

Great to hear that your FPGA deployment is working well with high confidence detections! You're absolutely right that avoiding SiLU was necessary for Vitis AI compatibility - this is a known trade-off when deploying to FPGA targets where certain activation functions aren't supported.

It sounds like you've successfully navigated the compatibility requirements while maintaining good model performance for your specific deployment scenario.

pderrenger avatar Jun 19 '25 23:06 pderrenger