ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
49.6k stars 16.1k forks source link

Low detection confidences after training for single class #1803

Closed AzharSindhi closed 3 years ago

AzharSindhi commented 3 years ago

After training for 480 epochs, results were okay on terminal. However in the inference detected objects have low detection confidences even on training images (not more than 0.5).

This isn't the problem for multi-class, because I have also trained yolov5 for three classes and it gave accurate bounding boxes with good confidence scores.

Besides low detection confidence, the mAP scores of single class are also lower compared to the model trained on three classes.

(Note that these scores are according to the best confidence threshold for each model found separately: 0.7 for three classes and 0.4 for one class)

Three class model scores

As we can see if we combine outgoing, incoming, and unknown vehicles to single class named vehicle, logically the scores should be close to the class with highest mAP above i.e. outgoing. However the results are as following:

Single class model scores

Please comment on why the confidence probability are lower in case of single class. Also what are your views about the scores of two models?

Thank you

Training Details

GPU: MSI Gaming X Trio RTX 3090 (24 GB)

My training bash script is: python train.py --img 640 --batch 8 --epochs 500 --data actors_1class.yaml --cfg yolov5l.yaml --device 0 --weights ''

I changed the nc variable to 1 in yolov5l.yaml file. Also modified actors_1class.yaml file accordingly.

github-actions[bot] commented 3 years ago

Hello @AzharSindhi, 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 screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

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

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 3 years ago

@AzharSindhi that's great you've developed your own metrics, but the best way to compare runs is simply to compare them in a common format by using the provided outputs, i.e. a link to your W&B project or overlay them on the same results.png file (by placing both results.txt files in the same folder and running plots.plot_results(save_dir=folder), mAP curves etc.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

biendltb commented 1 year ago

I found the same issue when comparing Yolov5 detection with my previous model Scaled Yolov4. Yolov5 gives lower detection confidence for classes.

glenn-jocher commented 10 months ago

@biendltb thanks for your feedback. YOLOv5 and YOLOv4 have different architectures and training methodologies, so it's expected to see differences in performance. If you need further assistance, feel free to ask!