Jihoon Kim commited on
Commit
fcb225c
β€’
1 Parent(s): aa18599

Shuffle all 4(or 9) images in mosaic augmentation (#4787)

Browse files

Thank you for sharing nice open-source codes πŸ‘

I applied to shuffle the order of all 4(or 9) images in mosaic augmentation

Currently, the order of images in mosaic augmentation is not completely random.
The remaining images except the first are randomly arranged. Apply shuffle all to increase the diversity of data composition.

Files changed (1) hide show
  1. utils/datasets.py +2 -0
utils/datasets.py CHANGED
@@ -661,6 +661,7 @@ def load_mosaic(self, index):
661
  s = self.img_size
662
  yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
663
  indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
 
664
  for i, index in enumerate(indices):
665
  # Load image
666
  img, _, (h, w) = load_image(self, index)
@@ -717,6 +718,7 @@ def load_mosaic9(self, index):
717
  labels9, segments9 = [], []
718
  s = self.img_size
719
  indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
 
720
  for i, index in enumerate(indices):
721
  # Load image
722
  img, _, (h, w) = load_image(self, index)
 
661
  s = self.img_size
662
  yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
663
  indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
664
+ random.shuffle(indices)
665
  for i, index in enumerate(indices):
666
  # Load image
667
  img, _, (h, w) = load_image(self, index)
 
718
  labels9, segments9 = [], []
719
  s = self.img_size
720
  indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
721
+ random.shuffle(indices)
722
  for i, index in enumerate(indices):
723
  # Load image
724
  img, _, (h, w) = load_image(self, index)