From bb7064ea648c24fc24c59fb41516f1918b11187c Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Mon, 11 Jan 2021 15:14:17 +0800 Subject: [PATCH] [DLMED] add more clear doc-string Signed-off-by: Nic Ma --- monai/inferers/inferer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/monai/inferers/inferer.py b/monai/inferers/inferer.py index 38755541f91..894a894954d 100644 --- a/monai/inferers/inferer.py +++ b/monai/inferers/inferer.py @@ -24,6 +24,19 @@ class Inferer(ABC): """ A base class for model inference. Extend this class to support operations during inference, e.g. a sliding window method. + + Example code:: + + device = torch.device("cuda:0") + data = ToTensor()(LoadImage(...)()).to(device) + model = UNet(...).to(device) + inferer = SlidingWindowInferer(...) + + model.eval() + with torch.no_grad(): + pred = inferer(inputs=data, network=model) + ... + """ @abstractmethod @@ -53,6 +66,7 @@ def __call__( class SimpleInferer(Inferer): """ SimpleInferer is the normal inference method that run model forward() directly. + Usage example can be found in the :py:class:`monai.inferers.Inferer` base class. """ @@ -83,6 +97,7 @@ class SlidingWindowInferer(Inferer): """ Sliding window method for model inference, with `sw_batch_size` windows for every model.forward(). + Usage example can be found in the :py:class:`monai.inferers.Inferer` base class. Args: roi_size: the window size to execute SlidingWindow evaluation.