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

How to minimise False positive? #4194

Closed akashAD98 closed 3 years ago

akashAD98 commented 3 years ago

❔Question

I have trained my model & its performing well on validation data, i got 82% MAP(@0.5), But when i tested my model on frames/video its giving few false predictions.

My dataset has 25 classes & each class has more than 2000 instances.

I have classes like blood,cigarette ,pipe,tank..etc

This are the few results

  1. for red color object its predicting blood, bloodof

humnbleddibn-car

2.I have class of alcohol & its detecting god but for For any bottle or bottlelike shape object its predicting Alcohol

bottler-alco

3.I have a class cigarette & it's detecting an object which looks like cigarette. ![cig](https://user-images.githubusercontent.com/62583018/127321555-1b832559-0594-452d-94bc-5f1713c947c1.pn

@glenn-jocher i already read the Thanks. Im looking for your suggetion

adrianholovaty commented 3 years ago

Try adding some images that have zero objects, as described in "background images" on this page.

akashAD98 commented 3 years ago

@adrianholovaty thanks for the reply, I have 2 question

  1. This background image consists of all class objects with no annotations ?? can you give 1 example of it ?? or its any kind of image which has zero objects (objects not present in my class ) ? or is its simple plan baground
  2. Apart from this there is no other way?
glenn-jocher commented 3 years ago

@akashAD98 πŸ‘‹ Hello! Thanks for asking about improving YOLOv5 πŸš€ training results.

Most of the time good results can be obtained with no changes to the models or training settings, provided your dataset is sufficiently large and well labelled. If at first you don't get good results, there are steps you might be able to take to improve, but we always recommend users first train with all default settings before considering any changes. This helps establish a performance baseline and spot areas for improvement.

If you have questions about your training results we recommend you provide the maximum amount of information possible if you expect a helpful response, including results plots (train losses, val losses, P, R, mAP), PR curve, confusion matrix, training mosaics, test results and dataset statistics images such as labels.png. All of these are located in your project/name directory, typically yolov5/runs/train/exp.

We've put together a full guide for users looking to get the best results on their YOLOv5 trainings below.

Dataset

COCO Analysis

Model Selection

Larger models like YOLOv5x and YOLOv5x6 will produce better results in nearly all cases, but have more parameters, require more CUDA memory to train, and are slower to run. For mobile deployments we recommend YOLOv5s/m, for cloud deployments we recommend YOLOv5l/x. See our README table for a full comparison of all models.

YOLOv5 Models

Training Settings

Before modifying anything, first train with default settings to establish a performance baseline. A full list of train.py settings can be found in the train.py argparser.

Further Reading

If you'd like to know more a good place to start is Karpathy's 'Recipe for Training Neural Networks', which has great ideas for training that apply broadly across all ML domains: http://karpathy.github.io/2019/04/25/recipe/

akashAD98 commented 3 years ago

@adrianholovaty @glenn-jocher so background images are images with plan background?? how to determine what kind of background images needs to add according to use case? Note: please have look at my FP results. should i need to add this FP backround or its normal baground? it would be great if you give 1 exmple. Thank you so much!

I have 25 classes which are shotgun, pistol, rifle... but it's falling in real-world scenarios. doing too much false prediction. so what are the best background images for this use case???

shotgun

glenn-jocher commented 3 years ago

@akashAD98 this is pretty simple. Images without objects are background images. Find them whereever you want.

akashAD98 commented 3 years ago

@glenn-jocher got it .thanks

glenn-jocher commented 3 years ago

@akashAD98 the only criteria is of course the images shouldn't contain the classes you are training on, so you could include the image shown above as a background image (provided of course it's not in your val set).

majnas commented 3 years ago

So, for a background image AAA.jpg we have to have an empty AAA.txt or no txt file is needed?

glenn-jocher commented 3 years ago

@m-nasiri this is already answered in https://github.com/ultralytics/yolov5/issues/4194#issuecomment-888280050

github-actions[bot] commented 3 years ago

πŸ‘‹ Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 πŸš€ resources:

Access additional Ultralytics ⚑ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐!