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 (ultralytics#2383)

image weights compatible faster random index generator v2 for mosaic augmentation
  • Loading branch information
developer0hye committed Mar 6, 2021
1 parent 895a13d commit b9c287e
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 b9c287e

Please sign in to comment.