| Conditions | 4 |
| Total Lines | 23 |
| Code Lines | 20 |
| 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 | for n in 17, 27: |
||
| 17 | patch_size = 10, 15, n |
||
| 18 | patch_overlap = 4, 6, 8 |
||
| 19 | batch_size = 6 |
||
| 20 | |||
| 21 | grid_sampler = GridSampler(self.sample, patch_size, patch_overlap) |
||
| 22 | aggregator = GridAggregator(grid_sampler) |
||
| 23 | patch_loader = DataLoader(grid_sampler, batch_size=batch_size) |
||
| 24 | with torch.no_grad(): |
||
| 25 | for patches_batch in tqdm(patch_loader): |
||
| 26 | input_tensor = patches_batch['t1'][DATA] |
||
| 27 | locations = patches_batch[LOCATION] |
||
| 28 | logits = model(input_tensor) # some model |
||
| 29 | outputs = logits |
||
| 30 | aggregator.add_batch(outputs, locations) |
||
| 31 | |||
| 32 | output = aggregator.get_output_tensor() |
||
| 33 | assert (output == -5).all() |
||
| 34 |