Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1420 Enhance inferer document #1425

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions monai/inferers/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()(filename=img_path)).to(device)
model = UNet(...).to(device)
inferer = SlidingWindowInferer(...)

model.eval()
with torch.no_grad():
pred = inferer(inputs=data, network=model)
...

"""

@abstractmethod
Expand Down Expand Up @@ -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.

"""

Expand Down Expand Up @@ -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.
Expand Down