-
-
Notifications
You must be signed in to change notification settings - Fork 17k
Why the confusion matrix when I test the network only prints the first row? #13536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
👋 Hello @giuliohubb, thank you for reaching out and for your detailed explanation and examples! 😊 This is an automated response to let you know that your issue is being reviewed. An Ultralytics engineer will assist you soon. In the meantime, here are a few steps you can take to ensure we can better assist you:
RequirementsEnsure you are using Python>=3.8.0 and have installed all required dependencies from our requirements.txt, including PyTorch>=1.8. To check or update your environment, you can follow these steps: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 supports several verified environments with all dependencies preinstalled, such as:
StatusOur automated tests ensure that YOLOv5 works correctly across macOS, Windows, and Ubuntu for training, validation, inference, export, and benchmarking. You can check the status here: If the issue persists or you discover new details, feel free to update this thread. We appreciate your patience and contributions! 🚀 |
@giuliohubb the confusion matrix showing only the first row typically occurs when your model is overwhelmingly predicting one class (likely 'cosmics' due to severe class imbalance). This indicates the model isn't detecting other classes during validation. For small object detection, we recommend:
For confusion matrix interpretation, see our Confusion Matrix guide. To verify predictions, inspect |
@giuliohubb thanks for clarifying! You're correct that the normalized confusion matrix (first image) shows color-coded relative class distributions, but numerical values may be too small to display clearly in the first row due to class imbalance. For absolute counts, we recommend using Regarding image size differences: The mAP variance between 544/640px likely stems from your small objects benefiting from higher resolution during inference. For optimal results, maintain consistent train/val image sizes. |
Search before asking
Question
Hello!!
I am using YOLOv5 for a small object detection problem.
When I try to test the model after the training on the test set I use the val.py file with task = test and it works correctly. The only issue is that when it saves the confusion matrix it prints only the first row (Here's two examples, one with normalise = True and one with normalise = False).
Do you know why this is the case? I tried to look at the code but I've found no issues. I have three classes ['cosmics', 'stars', 'satellites'], cosmics are overrepresented - 63383 instances - followed by stars - 6365 instances - and satellites - 620 instances. The IOU thres is 0.5 and I haven't touched the conf_thres
Additional
One other thing:
the image size is 532, in training it has been rounded to 544 because it must be multiple of max stride 32. When I test the network if I put the same image size - 544 - it reaches a mAP = 0.658 while if I put image size = 640 it reaches a mAP = 0.852. Do you have an explanation for this behaviour? In training the image size was 544, reaching an mAP = 0.874. And the confusion matrix in the training is printed correctly (I put it down below). I have seen the documentation many times without finding those answers. Thank you very much for your help.
The text was updated successfully, but these errors were encountered: