ultralytics / yolov5

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

Train image size and image prediction size must have same pixels ? #974

Closed blinkbink closed 4 years ago

blinkbink commented 4 years ago

❔Question

  1. in Yolov5, i trained 1000 data image with random image size, like 1024x768 or 640x480 etc, is it wrong ?
  2. trained required same size ? Example 640x640 all for data trained ?
  3. data image to predict must have same size with data trained, example trained data is 640x480 then test image have size 1024x768 ?

Thank you

github-actions[bot] commented 4 years ago

Hello @blinkbink, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

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 model or data training question, please note Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

For more information please visit https://www.ultralytics.com.

NanoCode012 commented 4 years ago

You don’t need to resize them manually. It just works which is great.

I don’t know if there’s a “perfect” image size to use. It should be up to your experiment.

luvwinnie commented 4 years ago

i took a dataset with 4k and trained with 640, however, it seems like I need to use --img-size=3840 with detect.py to detect correctly, anyway to get the best performance for any size?

glenn-jocher commented 4 years ago

@luvwinnie train and detect at the same --img-size for best results.

blinkbink commented 4 years ago

@glenn-jocher how about the size on training data but with base width is 640, i mean the base width is 640 but have various height like 320x640, 480x640, 221x640, so just can resize by width, not both height and width, because if i resize with same size 640x640 got strecth image

glenn-jocher commented 4 years ago

@blinkbink train and detect at the same --img-size for best results, such as the default --img 640.

blinkbink commented 4 years ago

yes sorry, i don't understand, i mean --image-size 640 is for 640x640 right ? how about various like 480x640, 320x640, 211x640 ?

glenn-jocher commented 4 years ago

@blinkbink you only supply the longest dimension, --img 640. The rest is handled automatically.

K-A-B-I-L-A-N commented 2 years ago

I have some few questions. Since I am a beginner to this bear with my innocence in this;

  1. For my project since it is an embedded application i decided to go with the fastest v6.0 yolov5n.pt (currently). Since it was pretrained on size - 640 pixels should i also custom train it at only 640 pixels or can i bump it up to higher pixels (say 1280 pixels)?
  2. My image dataset consists of images with resolutions like 400320 and also 31204160. So my question is, To get the best results should i reduce the resolution of higher resolution images or can it be the same way as it is?
glenn-jocher commented 2 years ago

@kabilan-2001 for fastest results run at lower imgsz, for more accurate results run at higher imgsz.

For large objects use YOLOv5n6 rather than YOLOv5n.

K-A-B-I-L-A-N commented 2 years ago

@glenn-jocher Thanks for your inputs. I saw somewhere like to know the exact training image size we should be resizing the image and check whether the custom object to be trained on is visible to our eye. Is that way crct to analyze and pick a particular image size for training?

And also training on lower image size will reduce training time. But will it reduce inference times while testing ?

glenn-jocher commented 2 years ago

@oguzaktas inference sizes are independent of image sizes, with larger inference sizes produce better mAP at slower speeds. The compromise is your choice based on your priorities, I can't choose for you. See Tips for Best Training Results tutorial for more details.

YOLOv5 Tutorials

Good luck 🍀 and let us know if you have any other questions!