Augment the size of the cells mask in the environment, by dilating the size of the cell with random kernel
(x)
| 34 | |
| 35 | |
| 36 | def env_shape_aug(x): |
| 37 | """ |
| 38 | Augment the size of the cells mask in the environment, |
| 39 | by dilating the size of the cell with random kernel |
| 40 | """ |
| 41 | if np.random.random() < 0.5: |
| 42 | cell_mask = x[:, :, -2] |
| 43 | kernel_size = np.random.choice([2, 3, 5]) |
| 44 | kernel = np.ones(kernel_size, np.uint8) |
| 45 | img_dilation = cv2.dilate(cell_mask, kernel, iterations=1) |
| 46 | x[:, :, -2] = img_dilation |
| 47 | return x |
| 48 | |
| 49 | |
| 50 | val_transform = lambda crop_size: torchvision.transforms.Compose([ |
nothing calls this directly
no outgoing calls
no test coverage detected