(img, gt, size)
| 171 | |
| 172 | |
| 173 | def random_crop(img, gt, size): |
| 174 | if isinstance(size, numbers.Number): |
| 175 | size = (int(size), int(size)) |
| 176 | else: |
| 177 | size = size |
| 178 | |
| 179 | h, w = img.shape[:2] |
| 180 | crop_h, crop_w = size[0], size[1] |
| 181 | |
| 182 | if h > crop_h: |
| 183 | x = random.randint(0, h - crop_h + 1) |
| 184 | img = img[x : x + crop_h, :, :] |
| 185 | gt = gt[x : x + crop_h, :] |
| 186 | |
| 187 | if w > crop_w: |
| 188 | x = random.randint(0, w - crop_w + 1) |
| 189 | img = img[:, x : x + crop_w, :] |
| 190 | gt = gt[:, x : x + crop_w] |
| 191 | |
| 192 | return img, gt |
| 193 | |
| 194 | |
| 195 | def normalize(img, mean, std): |
nothing calls this directly
no outgoing calls
no test coverage detected