Unverified 提交 fcb225c1 authored 作者: Jihoon Kim's avatar Jihoon Kim 提交者: GitHub

Shuffle all 4(or 9) images in mosaic augmentation (#4787)

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.
上级 aa185990
...@@ -661,6 +661,7 @@ def load_mosaic(self, index): ...@@ -661,6 +661,7 @@ def load_mosaic(self, index):
s = self.img_size s = self.img_size
yc, xc = [int(random.uniform(-x, 2 * s + x)) for x in self.mosaic_border] # mosaic center x, y 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 indices = [index] + random.choices(self.indices, k=3) # 3 additional image indices
random.shuffle(indices)
for i, index in enumerate(indices): for i, index in enumerate(indices):
# Load image # Load image
img, _, (h, w) = load_image(self, index) img, _, (h, w) = load_image(self, index)
...@@ -717,6 +718,7 @@ def load_mosaic9(self, index): ...@@ -717,6 +718,7 @@ def load_mosaic9(self, index):
labels9, segments9 = [], [] labels9, segments9 = [], []
s = self.img_size s = self.img_size
indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices indices = [index] + random.choices(self.indices, k=8) # 8 additional image indices
random.shuffle(indices)
for i, index in enumerate(indices): for i, index in enumerate(indices):
# Load image # Load image
img, _, (h, w) = load_image(self, index) img, _, (h, w) = load_image(self, index)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论