ultralytics / yolov5

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

imperfect precision but perfect mAPs #1493

Closed sammilei closed 3 years ago

sammilei commented 3 years ago

❔Question

Hi, I am fine-tuning a single class model with yolov5l.pt and confused by the high mAP at all the testing sets. The model did not perform perfectly on its validation set but it shows perfect scores as 1 or .0999 at mAP.5 and mAP.5:0.95 at test sets even if precision is not 1. Also, the label was almost perfect too. A lot of the time, they perfectly overlay with my labels.

Additional context

one test result: !python test.py --weights "/content/yolov5/runs/train/exp/weights/best.pt" --data /content/ms.yaml --img 416 --task test --save-txt --verbose --conf-thres 0.5 --save-conf

Namespace(augment=False, batch_size=32, conf_thres=0.5, data='/content/ms.yaml', device='', exist_ok=False, img_size=416, iou_thres=0.6, name='exp', project='runs/test', save_conf=True, save_json=False, save_txt=True, single_cls=False, task='test', verbose=True, weights=['/content/yolov5/runs/train/2_backpack_br_dk/weights/best.pt'])
Using torch 1.7.0+cu101 CUDA:0 (Tesla V100-SXM2-16GB, 16130MB)

Fusing layers... 
Model Summary: 400 layers, 47790077 parameters, 0 gradients
Scanning labels /content/tunnel_backpack_s120_s20000_img/labels/val.cache (590 found, 0 missing, 0 empty, 0 duplicate, for 590 images): 590it [00:00, 17918.67it/s]
               Class      Images     Targets           P           R      mAP@.5  mAP@.5:.95: 100% 19/19 [00:06<00:00,  3.05it/s]
                 all         590         590       0.958           1           1           1
              person         590         590       0.958           1           1           1
Speed: 1.4/2.1/3.4 ms inference/NMS/total per 416x416 image at batch-size 32
Results saved to runs/test/exp14
590 labels saved to runs/test/exp14/labels

training plot: results

Does anyone know what happened? Anything I did wrong?

github-actions[bot] commented 3 years ago

Hello @sammilei, 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

@sammilei P and R are computed at conf 0.1: https://github.com/ultralytics/yolov5/blob/7aeef2dca518916a13b7e516505a87c2e77155fd/utils/metrics.py#L41

mAP is computed at conf 0.001: https://github.com/ultralytics/yolov5/blob/7aeef2dca518916a13b7e516505a87c2e77155fd/test.py#L287

sammilei commented 3 years ago

I see what happened. My bad. Thanks, @glenn-jocher for your kind reminder!

bonorico commented 3 years ago

I think this might be also related to this issue https://github.com/ultralytics/yolov5/issues/1563, since I see u flagged save-txt in zour command ....