Inference with exported learner

#all_skip
from fastMONAI.vision_all import *

from monai.apps import DecathlonDataset
#task = 'Task09_Spleen'
task = 'Task01_BrainTumour'
path = Path('../data')
path.mkdir(exist_ok=True)
test_data = DecathlonDataset(root_dir=path, task=task, section="test", download=True,
                                 cache_num=0, num_workers=3)
test_imgs = [data['image'] for data in test_data.data]
learn_inf = load_learner('braintumor_model.pkl', cpu=False);
_, reorder, resample = load_variables(pkl_fn='vars.pkl')
reorder, resample
(False, [1.0, 1.0, 1.0])
save_path = Path('../data/results/braintumor')
path.mkdir(parents=True, exist_ok=True)
idx = 3
img_fn = test_imgs[idx]
pred_fn = inference(learn_inf, reorder, resample, fn, save_path=save_path)
from torchio import Subject, ScalarImage, LabelMap

subject = Subject(image=ScalarImage(img_fn), mask=LabelMap(pred_fn))
subject.plot(figsize=(10,5))