Ultralytics Code Refactor https://ultralytics.com/actions (#13153)
* Refactor code for speed and clarity * Update dataloaders.py Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> --------- Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
1 parent
b9019671f4
commit
100a423b66
14 files changed
+30
No files matched your search
@@ -174,6 +174,7 @@ def create_dataloader(
|
||||
shuffle=False,
|
||||
seed=0,
|
||||
):
|
||||
"""Creates and returns a configured DataLoader instance for loading and processing image datasets."""
|
||||
if rect and shuffle:
|
||||
LOGGER.warning("WARNING ⚠️ --rect is incompatible with DataLoader shuffle, setting shuffle=False")
|
||||
shuffle = False
|
||||
@@ -552,6 +553,7 @@ class LoadImagesAndLabels(Dataset):
|
||||
rank=-1,
|
||||
seed=0,
|
||||
):
|
||||
"""Initializes the YOLOv5 dataset loader, handling images and their labels, caching, and preprocessing."""
|
||||
self.img_size = img_size
|
||||
self.augment = augment
|
||||
self.hyp = hyp
|
||||
@@ -1351,6 +1353,7 @@ def create_classification_dataloader(
|
||||
path, imgsz=224, batch_size=16, augment=True, cache=False, rank=-1, workers=8, shuffle=True
|
||||
):
|
||||
# Returns Dataloader object to be used with YOLOv5 Classifier
|
||||
"""Creates a DataLoader for image classification, supporting caching, augmentation, and distributed training."""
|
||||
with torch_distributed_zero_first(rank): # init dataset *.cache only once if DDP
|
||||
dataset = ClassificationDataset(root=path, imgsz=imgsz, augment=augment, cache=cache)
|
||||
batch_size = min(batch_size, len(dataset))
|
||||
|
||||
Reference in new issue
Block a user