| Conditions | 3 |
| Total Lines | 19 |
| Code Lines | 17 |
| 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, 6, 8 |
||
| 16 | batch_size = 6 |
||
| 17 | |||
| 18 | grid_sampler = GridSampler(self.sample, patch_size, patch_overlap) |
||
| 19 | aggregator = GridAggregator(grid_sampler) |
||
| 20 | patch_loader = DataLoader(grid_sampler, batch_size=batch_size) |
||
| 21 | with torch.no_grad(): |
||
| 22 | for patches_batch in tqdm(patch_loader): |
||
| 23 | input_tensor = patches_batch['t1'][DATA] |
||
| 24 | locations = patches_batch[LOCATION] |
||
| 25 | logits = model(input_tensor) # some model |
||
| 26 | labels = logits.argmax(dim=CHANNELS_DIMENSION, keepdim=True) |
||
| 27 | outputs = labels |
||
| 28 | aggregator.add_batch(outputs, locations) |
||
| 29 | |||
| 30 | aggregator.get_output_tensor() |
||
| 31 |