Occlusion augmentation
(self, img1, img2, bounds=[50, 100])
| 53 | return img1, img2 |
| 54 | |
| 55 | def eraser_transform(self, img1, img2, bounds=[50, 100]): |
| 56 | """ Occlusion augmentation """ |
| 57 | |
| 58 | ht, wd = img1.shape[:2] |
| 59 | if np.random.rand() < self.eraser_aug_prob: |
| 60 | mean_color = np.mean(img2.reshape(-1, 3), axis=0) |
| 61 | for _ in range(np.random.randint(1, 3)): |
| 62 | x0 = np.random.randint(0, wd) |
| 63 | y0 = np.random.randint(0, ht) |
| 64 | dx = np.random.randint(bounds[0], bounds[1]) |
| 65 | dy = np.random.randint(bounds[0], bounds[1]) |
| 66 | img2[y0:y0+dy, x0:x0+dx, :] = mean_color |
| 67 | |
| 68 | return img1, img2 |
| 69 | |
| 70 | def spatial_transform(self, img1, img2, flow): |
| 71 | # randomly sample scale |