Fix bug when enable --quad
training option
#13355
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When enabling the
--quad
training option, thecollate_fn4
function assumes the batch size will be greater than 4, but without enablingdrop_last
in the dataloader, the size of the last batch is unpredictable. So in some cases, an Exception may be raised, depending on the size of the dataset.n
will be zero, if batch size per GPU is smaller than 4.yolov5/utils/dataloaders.py
Line 1032 in a355524
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Added
drop_last
parameter to data loaders for improved batch handling.📊 Key Changes
drop_last
argument tocreate_dataloader()
function in bothdataloaders.py
andsegment/dataloaders.py
.🎯 Purpose & Impact
quad
parameter.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
This PR introduces an enhancement to the data loading process for YOLOv5 by incorporating the
drop_last
parameter to better handle batched data.📊 Key Changes
drop_last=quad
parameter in the data loader configurations withinutils/dataloaders.py
andutils/segment/dataloaders.py
.🎯 Purpose & Impact
drop_last
parameter helps manage batches more effectively, particularly when using "quad" mode, by dropping the last incomplete batch if it's smaller than the set batch size.