Exemplo n.º 1
0
    def __call__(self, input):
        size = round(np.random.uniform(self.min_size, self.max_size))
        input = Resize(size)(input)

        return input
Exemplo n.º 2
0
                                   if tta else eval_image_transform)
to_tensor = ToTensor()

if config.normalize is None:
    normalize = T.Compose([])
elif config.normalize == 'experiment':
    normalize = NormalizeByExperimentStats(
        torch.load('./experiment_stats.pth'))
elif config.normalize == 'plate':
    normalize = NormalizeByPlateStats(torch.load('./plate_stats.pth'))
else:
    raise AssertionError('invalid normalization {}'.format(config.normalize))

eval_image_transform = T.Compose([
    RandomSite(),
    Resize(config.resize_size),
    center_crop,
    to_tensor,
])
test_image_transform = T.Compose([
    Resize(config.resize_size),
    center_crop,
    SplitInSites(),
    T.Lambda(lambda xs: torch.stack([to_tensor(x) for x in xs], 0)),
])
train_transform = T.Compose([
    ApplyTo(['image'],
            T.Compose([
                RandomSite(),
                Resize(config.resize_size),
                random_crop,