From cd8ed3521d98ea120d07f57ea5372c4b375241ca Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Sat, 6 Mar 2021 15:58:26 +0900 Subject: [PATCH] image weights compatible faster random index generator v2 for mosaic augmentation (#2383) image weights compatible faster random index generator v2 for mosaic augmentation --- utils/datasets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index d6ab16518034..ed18f449ddd3 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -666,7 +666,7 @@ def load_mosaic(self, index): labels4, segments4 = [], [] 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] + [self.indices[random.randint(0, self.n - 1)] for _ in range(3)] # 3 additional image indices + indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices for i, index in enumerate(indices): # Load image img, _, (h, w) = load_image(self, index) @@ -721,7 +721,7 @@ def load_mosaic9(self, index): labels9, segments9 = [], [] s = self.img_size - indices = [index] + [self.indices[random.randint(0, self.n - 1)] for _ in range(8)] # 8 additional image indices + indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices for i, index in enumerate(indices): # Load image img, _, (h, w) = load_image(self, index)