developer0hye commited on
Commit
cd8ed35
·
unverified ·
1 Parent(s): c64fe21

image weights compatible faster random index generator v2 for mosaic augmentation (#2383)

Browse files
Files changed (1) hide show
  1. utils/datasets.py +2 -2
utils/datasets.py CHANGED
@@ -666,7 +666,7 @@ def load_mosaic(self, index):
666
  labels4, segments4 = [], []
667
  s = self.img_size
668
  yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
669
- indices = [index] + [self.indices[random.randint(0, self.n - 1)] for _ in range(3)] # 3 additional image indices
670
  for i, index in enumerate(indices):
671
  # Load image
672
  img, _, (h, w) = load_image(self, index)
@@ -721,7 +721,7 @@ def load_mosaic9(self, index):
721
 
722
  labels9, segments9 = [], []
723
  s = self.img_size
724
- indices = [index] + [self.indices[random.randint(0, self.n - 1)] for _ in range(8)] # 8 additional image indices
725
  for i, index in enumerate(indices):
726
  # Load image
727
  img, _, (h, w) = load_image(self, index)
 
666
  labels4, segments4 = [], []
667
  s = self.img_size
668
  yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
669
+ indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
670
  for i, index in enumerate(indices):
671
  # Load image
672
  img, _, (h, w) = load_image(self, index)
 
721
 
722
  labels9, segments9 = [], []
723
  s = self.img_size
724
+ indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
725
  for i, index in enumerate(indices):
726
  # Load image
727
  img, _, (h, w) = load_image(self, index)