| Conditions | 3 |
| Total Lines | 22 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import torch |
||
| 11 | def test_inference(self): |
||
| 12 | def model(tensor): |
||
| 13 | tensor[:] = -5 |
||
| 14 | return tensor |
||
| 15 | |||
| 16 | patch_size = 10, 15, 27 |
||
| 17 | patch_overlap = 4, 6, 8 |
||
| 18 | batch_size = 6 |
||
| 19 | |||
| 20 | grid_sampler = GridSampler(self.sample, patch_size, patch_overlap) |
||
| 21 | aggregator = GridAggregator(grid_sampler) |
||
| 22 | patch_loader = DataLoader(grid_sampler, batch_size=batch_size) |
||
| 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 | outputs = logits |
||
| 29 | aggregator.add_batch(outputs, locations) |
||
| 30 | |||
| 31 | output = aggregator.get_output_tensor() |
||
| 32 | assert (output == -5).all() |
||
| 33 |