| Conditions | 3 |
| Total Lines | 21 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import torch |
||
| 12 | def test_inference(self): |
||
| 13 | model = nn.Conv3d(1, 1, 3) |
||
| 14 | patch_size = 10, 15, 27 |
||
| 15 | patch_overlap = 4, 5, 8 |
||
| 16 | batch_size = 6 |
||
| 17 | CHANNELS_DIMENSION = 1 |
||
| 18 | |||
| 19 | grid_sampler = GridSampler(self.sample, patch_size, patch_overlap) |
||
| 20 | patch_loader = DataLoader(grid_sampler, batch_size=batch_size) |
||
| 21 | aggregator = GridAggregator(self.sample, patch_overlap) |
||
| 22 | |||
| 23 | with torch.no_grad(): |
||
| 24 | for patches_batch in tqdm(patch_loader): |
||
| 25 | input_tensor = patches_batch['t1'][DATA] |
||
| 26 | locations = patches_batch[LOCATION] |
||
| 27 | logits = model(input_tensor) # some model |
||
| 28 | labels = logits.argmax(dim=CHANNELS_DIMENSION, keepdim=True) |
||
| 29 | outputs = labels |
||
| 30 | aggregator.add_batch(outputs, locations) |
||
| 31 | |||
| 32 | aggregator.get_output_tensor() |
||
| 33 |