* 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:
Glenn Jocher authored and GitHub committed 2024-07-01 00:17:24 +02:00
1 parent b9019671f4
commit 100a423b66
14 files changed
+30

No files matched your search

+1
View File
@@ -30,6 +30,7 @@ def random_perspective(
# torchvision.transforms.RandomAffine(degrees=(-10, 10), translate=(.1, .1), scale=(.9, 1.1), shear=(-10, 10))
# targets = [cls, xyxy]
"""Applies random perspective, rotation, scale, shear, and translation augmentations to an image and targets."""
height = im.shape[0] + border[0] * 2 # shape(h,w,c)
width = im.shape[1] + border[1] * 2
+2
View File
@@ -39,6 +39,7 @@ def create_dataloader(
overlap_mask=False,
seed=0,
):
"""Creates a dataloader for training, validating, or testing YOLO models with various dataset options."""
if rect and shuffle:
LOGGER.warning("WARNING ⚠️ --rect is incompatible with DataLoader shuffle, setting shuffle=False")
shuffle = False
@@ -102,6 +103,7 @@ class LoadImagesAndLabelsAndMasks(LoadImagesAndLabels): # for training/testing
rank=-1,
seed=0,
):
"""Initializes the dataset with image, label, and mask loading capabilities for training/testing."""
super().__init__(
path,
img_size,