(self, sample)
| 219 | self.output_size = output_size |
| 220 | |
| 221 | def __call__(self, sample): |
| 222 | image, landmarks = sample['image'], sample['landmarks'] |
| 223 | |
| 224 | h, w = image.shape[:2] |
| 225 | if isinstance(self.output_size, int): |
| 226 | if h > w: |
| 227 | new_h, new_w = self.output_size * h / w, self.output_size |
| 228 | else: |
| 229 | new_h, new_w = self.output_size, self.output_size * w / h |
| 230 | else: |
| 231 | new_h, new_w = self.output_size |
| 232 | |
| 233 | new_h, new_w = int(new_h), int(new_w) |
| 234 | |
| 235 | img = transform.resize(image, (new_h, new_w)) |
| 236 | |
| 237 | # h and w are swapped for landmarks because for images, |
| 238 | # x and y axes are axis 1 and 0 respectively |
| 239 | landmarks = landmarks * [new_w / w, new_h / h] |
| 240 | |
| 241 | return {'image': img, 'landmarks': landmarks} |
| 242 | |
| 243 | |
| 244 | class RandomCrop(object): |
nothing calls this directly
no outgoing calls
no test coverage detected