Skip to content

Commit e3d3f4b

Browse files
authored
refactor: decompose PatchInferenceEngine.predict into pipelined stages (#69)
Split predict() into _prepare_subject, _run_inference, and _postprocess for better modularity. Add _PreparedSubject dataclass and _save_prediction helper. Switch from torch.no_grad to torch.inference_mode for faster inference.
1 parent 4e8654f commit e3d3f4b

3 files changed

Lines changed: 229 additions & 111 deletions

File tree

fastMONAI/_modidx.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,18 @@
553553
'fastMONAI/vision_patch.py'),
554554
'fastMONAI.vision_patch.PatchInferenceEngine.__init__': ( 'vision_patch.html#patchinferenceengine.__init__',
555555
'fastMONAI/vision_patch.py'),
556+
'fastMONAI.vision_patch.PatchInferenceEngine._postprocess': ( 'vision_patch.html#patchinferenceengine._postprocess',
557+
'fastMONAI/vision_patch.py'),
558+
'fastMONAI.vision_patch.PatchInferenceEngine._prepare_subject': ( 'vision_patch.html#patchinferenceengine._prepare_subject',
559+
'fastMONAI/vision_patch.py'),
560+
'fastMONAI.vision_patch.PatchInferenceEngine._run_inference': ( 'vision_patch.html#patchinferenceengine._run_inference',
561+
'fastMONAI/vision_patch.py'),
556562
'fastMONAI.vision_patch.PatchInferenceEngine.predict': ( 'vision_patch.html#patchinferenceengine.predict',
557563
'fastMONAI/vision_patch.py'),
558564
'fastMONAI.vision_patch.PatchInferenceEngine.to': ( 'vision_patch.html#patchinferenceengine.to',
559565
'fastMONAI/vision_patch.py'),
566+
'fastMONAI.vision_patch._PreparedSubject': ( 'vision_patch.html#_preparedsubject',
567+
'fastMONAI/vision_patch.py'),
560568
'fastMONAI.vision_patch._extract_tio_transform': ( 'vision_patch.html#_extract_tio_transform',
561569
'fastMONAI/vision_patch.py'),
562570
'fastMONAI.vision_patch._get_default_device': ( 'vision_patch.html#_get_default_device',
@@ -565,6 +573,8 @@
565573
'fastMONAI/vision_patch.py'),
566574
'fastMONAI.vision_patch._predict_patch_tta': ( 'vision_patch.html#_predict_patch_tta',
567575
'fastMONAI/vision_patch.py'),
576+
'fastMONAI.vision_patch._save_prediction': ( 'vision_patch.html#_save_prediction',
577+
'fastMONAI/vision_patch.py'),
568578
'fastMONAI.vision_patch._warn_config_override': ( 'vision_patch.html#_warn_config_override',
569579
'fastMONAI/vision_patch.py'),
570580
'fastMONAI.vision_patch.create_patch_sampler': ( 'vision_patch.html#create_patch_sampler',

0 commit comments

Comments
 (0)