ultralytics / yolov5

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

Inference time vs. img_size #1704

Closed yueli822ms closed 3 years ago

yueli822ms commented 3 years ago

❔Question

During my verification, I found the when the image size is larger than 600, reducing the image size can significantly reduce the inference time, but this is not the case for image size smaller than 600. For example, the inference time is 16.9ms for img_size=640 and 15.5ms for img_size=64. Although the size difference is 10x, the inference time differs little. Could you please kindly provide me some information on why this happens? Thank you!

Additional context

github-actions[bot] commented 3 years ago

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

@yueli822ms not all operations scale with size. This is an open ended computer science questions, but in general do not expect zero inference time as your image size trends to zero.

JoJoliking commented 3 years ago

@glenn-jocher Dear Author: Hello! I have a question about the image input size. Yolov5 uses a square image as network input by default. When I am switching to rectangular image for training, the length and width of the input image will be automatically read, but the length and width of the image will be different due to different image sizes. So can I use fixed image length and width for training? (for example: 640 * 480 for all images)

glenn-jocher commented 3 years ago

@JoJoliking you can train with --rect to train on minimum batch rectangle sizes, or use default settings to train with --img-size square mosaics.

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.