Convert ndarrays in sample to Tensors.
| 275 | |
| 276 | |
| 277 | class ToTensor(object): |
| 278 | """Convert ndarrays in sample to Tensors.""" |
| 279 | |
| 280 | def __call__(self, sample): |
| 281 | image, landmarks = sample['image'], sample['landmarks'] |
| 282 | |
| 283 | # swap color axis because |
| 284 | # numpy image: H x W x C |
| 285 | # torch image: C x H x W |
| 286 | image = image.transpose((2, 0, 1)) |
| 287 | return {'image': torch.from_numpy(image), |
| 288 | 'landmarks': torch.from_numpy(landmarks)} |
| 289 | |
| 290 | ###################################################################### |
| 291 | # .. note:: |
no outgoing calls
no test coverage detected