(self, sample)
| 31 | self.output_size = output_size |
| 32 | |
| 33 | def __call__(self, sample): |
| 34 | image, label = sample['image'], sample['label'] |
| 35 | |
| 36 | if random.random() > 0.5: |
| 37 | image, label = random_rot_flip(image, label) |
| 38 | elif random.random() > 0.5: |
| 39 | image, label = random_rotate(image, label) |
| 40 | x, y = image.shape |
| 41 | if x != self.output_size[0] or y != self.output_size[1]: |
| 42 | image = zoom(image, (self.output_size[0] / x, self.output_size[1] / y), order=3) # why not 3? |
| 43 | label = zoom(label, (self.output_size[0] / x, self.output_size[1] / y), order=0) |
| 44 | image = torch.from_numpy(image.astype(np.float32)).unsqueeze(0) |
| 45 | label = torch.from_numpy(label.astype(np.float32)) |
| 46 | sample = {'image': image, 'label': label.long()} |
| 47 | return sample |
| 48 | |
| 49 | |
| 50 | class Synapse_dataset(Dataset): |
nothing calls this directly
no test coverage detected