MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / __call__

Method __call__

utils/dataset_synapse.py:33–47  ·  view source on GitHub ↗
(self, sample)

Source from the content-addressed store, hash-verified

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
50class Synapse_dataset(Dataset):

Callers

nothing calls this directly

Calls 2

random_rot_flipFunction · 0.70
random_rotateFunction · 0.70

Tested by

no test coverage detected