Yolov5: how to train non-square images?

Created on 13 Sep 2020  Â·  11Comments  Â·  Source: ultralytics/yolov5

Hi there, thankyou for this interesting new OD framework!

Please could you explain the params:

depth_multiple: 0.33  # model depth multiple
width_multiple: 0.50  # layer channel multiple

How can I specify that I wish to train at a particular (non-square) aspect ratio? how can I set the width/height, batch-size etc ?

Is it possible to configure which augmentations are used or even to add my own?

Stale question

Most helpful comment

@LukeAI python train.py --rect will use rectangular inference for training. python train.py --batch 8 will set batch size. See train.py for full list of argparser arguments.

See hyperparameter files for augmentation parameters.
https://github.com/ultralytics/yolov5/blob/806e75f2b1166a4a789e0ea70b0e48064005f5c9/data/hyp.scratch.yaml#L1-L29

All 11 comments

Hello @LukeAI, 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:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

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

@LukeAI python train.py --rect will use rectangular inference for training. python train.py --batch 8 will set batch size. See train.py for full list of argparser arguments.

See hyperparameter files for augmentation parameters.
https://github.com/ultralytics/yolov5/blob/806e75f2b1166a4a789e0ea70b0e48064005f5c9/data/hyp.scratch.yaml#L1-L29

I used the --rect arg but when I train the opt.yaml file still says:
img_size:

  • 1600
  • 1600

@davodogster no changes are needed for training differently sized images. The default training command trains on images of any shape and size.

The two image sizes shown are train and test image sizes, both 1600 in your case.

Hi I want to train on a rectangle size image like width 1600, height 800 (approx) .. but img-size only takes one integer value.

Sam


From: Glenn Jocher notifications@github.com
Sent: Friday, September 18, 2020 10:33:54 AM
To: ultralytics/yolov5 yolov5@noreply.github.com
Cc: Sam Davidson sjd166@uclive.ac.nz; Mention mention@noreply.github.com
Subject: Re: [ultralytics/yolov5] how to train non-square images? (#961)

@davodogsterhttps://github.com/davodogster no changes are needed for training differently sized images. The default training command trains on images of any shape and size.

The two image sizes shown are train and test image sizes, both 1600 in your case.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/ultralytics/yolov5/issues/961#issuecomment-694535282, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK7R4HDIVVMBSK6AHVNTQ7DSGKFFFANCNFSM4RKUYT5Q.

Hi I want to train on a rectangle size image like width 1600, height 800 (approx) .. but img-size only takes one integer value. Sam
…
________________________________ From: Glenn Jocher notifications@github.com Sent: Friday, September 18, 2020 10:33:54 AM To: ultralytics/yolov5 yolov5@noreply.github.com Cc: Sam Davidson sjd166@uclive.ac.nz; Mention mention@noreply.github.com Subject: Re: [ultralytics/yolov5] how to train non-square images? (#961) @davodogsterhttps://github.com/davodogster no changes are needed for training differently sized images. The default training command trains on images of any shape and size. The two image sizes shown are train and test image sizes, both 1600 in your case. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#961 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AK7R4HDIVVMBSK6AHVNTQ7DSGKFFFANCNFSM4RKUYT5Q.

Have you solved the problem ? How did you solve it ?

Bigger side will get the img-size you define and other side will shrink according to aspect ratio of the image and get padded to become squared image of img-sixe x img-size. Hope this helps, you can view this in the images that get created when you start the training.

Bigger side will get the img-size you define and other side will shrink according to aspect ratio of the image and get padded to become squared image of img-sixe x img-size. Hope this helps, you can view this in the images that get created when you start the training.

Thanks for your reply, Please just tell me what should i do or where should i modify the code if i want to achieve non-square training ?

@china56321 python train.py --rect

@china56321 python train.py --rect

it seems train --rect can not use mosaic augmentation?

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KangHoyong picture KangHoyong  Â·  3Comments

cswwp picture cswwp  Â·  4Comments

Alex-afka picture Alex-afka  Â·  3Comments

jaqub-manuel picture jaqub-manuel  Â·  4Comments

FSNStefan picture FSNStefan  Â·  4Comments