ultralytics / yolov5

YOLOv5 πŸš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.76k stars 16.34k forks source link

How about low resolution images #3084

Closed lixinghe1999 closed 3 years ago

lixinghe1999 commented 3 years ago

❔Question

I am dealing with a custom dataset with low resolution (160 * 128). From my understanding, I should use --img 160 --rect, but the result seems not so good. An alternative way is resize the low resolution to 640, and use --img 640 instead. Maybe the ways above are completely the same thing, or one of them is better.

Or, due to the fact the checkpoints are trained from 640 images. For better result, I need to train from scratch?

Or, I just need to change hyperparameters?

So I wonder which part is correct? And may be the reason behind it? Thanks!

Lixing He

Additional context

github-actions[bot] commented 3 years ago

πŸ‘‹ Hello @lixinghe1999, 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

@lixinghe1999 πŸ‘‹ Hello! Thanks for asking about improving 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/

lixinghe1999 commented 3 years ago

Update from myself. Change img-size is enough to train image of different resolution, seems yolov5 is super adaptive. My experiment results show: 640: 80map, downsample to 320: 60map, dowmsample to 160: 30map. Downsample: bicubic.

glenn-jocher commented 3 years ago

@lixinghe1999 yeah your experiment sounds about right. Also note if you train at 640 you can still run inference at lower resolutions like 320, 160 later on also. If you train at 160, your best inference results will be at 160 or smaller.

maciej-autobon commented 3 years ago

@lixinghe1999 Glenn's suggestion to use a model trained on the 640 resolution to then run inference against 320 or even 160 images is actually super-valuable and in my case (160) I got a mAP of around 0.76 (give or take, it's not relevant what the exact number was) when using a model trained on 640 images, but a mAP of 0.61 when using a model trained on 160 images.

The intuition for that is: you do have low-resolution objects in the 640 images either way, the model can learn to detect them, but in addition to that you also have large objects which can still be valuable for learning more robust feature maps.

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 ⭐!