Skip to content

Commit

Permalink
image weights compatible faster random index generator v2 for mosaic …
Browse files Browse the repository at this point in the history
…augmentation (#2383)

image weights compatible faster random index generator v2 for mosaic augmentation
  • Loading branch information
developer0hye authored Mar 6, 2021
1 parent c64fe21 commit cd8ed35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cd8ed35

Please sign in to comment.