Skip to content

Commit

Permalink
faster random index generator for mosaic augementation
Browse files Browse the repository at this point in the history
We don't need to access list to generate random index

It makes augmentation slower.
  • Loading branch information
developer0hye authored and glenn-jocher committed Mar 5, 2021
1 parent e931b9d commit e2e785d
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.randint(0, self.n - 1) for _ in range(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.randint(0, self.n - 1) for _ in range(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 e2e785d

Please sign in to comment.