Skip to content

Commit

Permalink
allow the device to be None
Browse files Browse the repository at this point in the history
  • Loading branch information
stergioc committed May 24, 2024
1 parent 5a2f209 commit 5574945
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sopa/patches/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
patch_width: int,
level: int | None = 0,
magnification: int | None = None,
device: str = "cpu",
device: str = None,
):
self.image = image
self.patch_width = patch_width
Expand Down Expand Up @@ -121,7 +121,8 @@ def __init__(
log.error("Error retrieving the image mpp, skipping tile embedding.")
return False

self.model.to(device)
if device:
self.model.to(device)

def _torch_resize(self, tensor: torch.Tensor, resize_factor: float):
from torchvision.transforms import Resize
Expand Down Expand Up @@ -182,7 +183,7 @@ def infer_wsi_patches(
magnification: int | None = None,
image_key: str | None = None,
batch_size: int = 32,
device: str = "cpu",
device: str = None,
) -> SpatialImage | bool:
"""Create an image made of patch based predictions of a WSI image.
Expand Down

0 comments on commit 5574945

Please sign in to comment.