diff --git a/utils/datasets.py b/utils/datasets.py index ff053856..b462aa3a 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -276,6 +276,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing self.hyp = hyp self.image_weights = image_weights self.rect = False if image_weights else rect + self.mosaic = self.augment and not self.rect # load 4 images at a time into a mosaic (only during training) # Define labels self.label_files = [x.replace('images', 'labels').replace(os.path.splitext(x)[-1], '.txt') @@ -417,8 +418,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing label_path = self.label_files[index] hyp = self.hyp - mosaic = True and self.augment # load 4 images at a time into a mosaic (only during training) - if mosaic: + if self.mosaic: # Load mosaic img, labels = load_mosaic(self, index) shapes = None @@ -450,7 +450,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing if self.augment: # Augment imagespace - if not mosaic: + if not self.mosaic: img, labels = random_affine(img, labels, degrees=hyp['degrees'], translate=hyp['translate'],