-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why the inference speed when the image size is 224 is slower than the image size is 640? #5475
Comments
👋 Hello @daydayup-bit, 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://ultralytics.com or email Glenn Jocher at [email protected]. RequirementsPython>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started: $ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit. |
@daydayup-bit 👋 Hello! Thanks for asking about inference speed issues. YOLOv5 🚀 can be run on CPU (i.e. If you would like to increase your inference speed some options are:
detect.py inferencepython detect.py --weights yolov5s.pt --img 640 --conf 0.25 --source data/images/ YOLOv5 PyTorch Hub inferenceimport torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
# Images
dir = 'https://ultralytics.com/images/'
imgs = [dir + f for f in ('zidane.jpg', 'bus.jpg')] # batch of images
# Inference
results = model(imgs)
results.print() # or .show(), .save()
# Speed: 631.5ms pre-process, 19.2ms inference, 1.6ms NMS per image at shape (2, 3, 640, 640) |
@glenn-jocher Thank you very much for your answer. You said that reducing --img-size can increase the speed of inference, but on my machine, I found that this is not the case. When I use yolov5s to run detect.py on the GPU and enter a different --img-size, I get the following result.
As you can see, the inference time ranking is not the 224<320<480<640<1280 we expected, but 480<640<224<320<1280. I used a total of 180 images for detect. Why does this happen? I am very confused. |
@daydayup-bit I can't speak for your specific environment, but if your times don't improve then there's a constraint somewhere in your workflow unrelated to GPU or image size. |
Okay, thank you for your reply. |
@glenn-jocher Do you mean if I train model in larger batch size, I will get less inference time? |
@kuonumber @daydayup-bit we recently published a full inference speed vs batch size study here: |
@glenn-jocher WOW THAT'S REALLY COOL! |
Search before asking
Question
When i enter command
python val.py --data container_yolo/NEU-DET/data.yaml --weights runs/train/v5s_all_new/weights/best.pt --imgsz 640
,time of inference is 2.4ms,the result:when i enter command
python val.py --data container_yolo/NEU-DET/data.yaml --weights runs/train/v5s_all_new/weights/best.pt --imgsz 224
,time of inference is 4.1ms,which is slower than inputing 640. the result:Why the inference speed when the image size is 224 is slower than the image size is 640?
And, what are the main effects of these three parameters(pre-process,inference,NMS).Especially what affects the inference time?
Additional
No response
The text was updated successfully, but these errors were encountered: