Skip to content

Commit

Permalink
Shuffle all 4(or 9) images in mosaic augmentation (#4787)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kimnamu committed Sep 14, 2021
1 parent aa18599 commit fcb225c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ def load_mosaic(self, index):
s = self.img_size
yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y
indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
random.shuffle(indices)
for i, index in enumerate(indices):
# Load image
img, _, (h, w) = load_image(self, index)
Expand Down Expand Up @@ -717,6 +718,7 @@ def load_mosaic9(self, index):
labels9, segments9 = [], []
s = self.img_size
indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
random.shuffle(indices)
for i, index in enumerate(indices):
# Load image
img, _, (h, w) = load_image(self, index)
Expand Down

0 comments on commit fcb225c

Please sign in to comment.