From fcb225c1c81a17fbaeff027b1f4be5300049e8a8 Mon Sep 17 00:00:00 2001 From: Jihoon Kim <41357160+kimnamu@users.noreply.github.com> Date: Wed, 15 Sep 2021 07:57:06 +0900 Subject: [PATCH] Shuffle all 4(or 9) images in mosaic augmentation (#4787) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- utils/datasets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/datasets.py b/utils/datasets.py index cb6ad29..4a4b187 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -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) @@ -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)