Skip to content

Instantly share code, notes, and snippets.

@AlessandroMondin
Last active December 28, 2022 10:40
Show Gist options
  • Save AlessandroMondin/5d9220c664bb76d9bbf0320b99b09fab to your computer and use it in GitHub Desktop.
Save AlessandroMondin/5d9220c664bb76d9bbf0320b99b09fab to your computer and use it in GitHub Desktop.
if self.transform:
batch_n = idx // self.bs
if batch_n % 2 == 0:
self.transform[1].p = 1
else:
self.transform[1].p = 0
# albumentations requires bboxes to be (x,y,w,h,class_idx)
augmentations = self.transform(image=img,
bboxes=np.roll(labels, axis=1, shift=4)
)
img = augmentations["image"]
# loss fx requires bboxes to be (class_idx,x,y,w,h)
labels = np.array(augmentations["bboxes"])
if len(labels):
labels = np.roll(labels, axis=1, shift=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment