Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion monai/inferers/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class Inferer(ABC):
Example code::

device = torch.device("cuda:0")
data = ToTensor()(LoadImage()(filename=img_path)).to(device)
transform = Compose([ToTensor(), LoadImage(image_only=True)])
data = transform(img_path).to(device)
model = UNet(...).to(device)
inferer = SlidingWindowInferer(...)

Expand Down
3 changes: 2 additions & 1 deletion monai/transforms/utility/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def __init__(self, strict_check: bool = True):
strict_check: whether to raise an error when the meta information is insufficient.
"""
self.strict_check = strict_check
self.add_channel = AddChannel()

def __call__(self, img: NdarrayOrTensor, meta_dict: Optional[Mapping] = None) -> NdarrayOrTensor:
"""
Expand All @@ -223,7 +224,7 @@ def __call__(self, img: NdarrayOrTensor, meta_dict: Optional[Mapping] = None) ->
warnings.warn(msg)
return img
if channel_dim == "no_channel":
return AddChannel()(img)
return self.add_channel(img)
return AsChannelFirst(channel_dim=channel_dim)(img)


Expand Down