MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/inferers/inferer.py:502–552  ·  view source on GitHub ↗
(
        self,
        roi_size: Sequence[int] | int,
        sw_batch_size: int = 1,
        overlap: Sequence[float] | float = 0.25,
        mode: BlendMode | str = BlendMode.CONSTANT,
        sigma_scale: Sequence[float] | float = 0.125,
        padding_mode: PytorchPadMode | str = PytorchPadMode.CONSTANT,
        cval: float = 0.0,
        sw_device: torch.device | str | None = None,
        device: torch.device | str | None = None,
        progress: bool = False,
        cache_roi_weight_map: bool = False,
        cpu_thresh: int | None = None,
        buffer_steps: int | None = None,
        buffer_dim: int = -1,
        with_coord: bool = False,
    )

Source from the content-addressed store, hash-verified

500 """
501
502 def __init__(
503 self,
504 roi_size: Sequence[int] | int,
505 sw_batch_size: int = 1,
506 overlap: Sequence[float] | float = 0.25,
507 mode: BlendMode | str = BlendMode.CONSTANT,
508 sigma_scale: Sequence[float] | float = 0.125,
509 padding_mode: PytorchPadMode | str = PytorchPadMode.CONSTANT,
510 cval: float = 0.0,
511 sw_device: torch.device | str | None = None,
512 device: torch.device | str | None = None,
513 progress: bool = False,
514 cache_roi_weight_map: bool = False,
515 cpu_thresh: int | None = None,
516 buffer_steps: int | None = None,
517 buffer_dim: int = -1,
518 with_coord: bool = False,
519 ) -> None:
520 super().__init__()
521 self.roi_size = roi_size
522 self.sw_batch_size = sw_batch_size
523 self.overlap = overlap
524 self.mode: BlendMode = BlendMode(mode)
525 self.sigma_scale = sigma_scale
526 self.padding_mode = padding_mode
527 self.cval = cval
528 self.sw_device = sw_device
529 self.device = device
530 self.progress = progress
531 self.cpu_thresh = cpu_thresh
532 self.buffer_steps = buffer_steps
533 self.buffer_dim = buffer_dim
534 self.with_coord = with_coord
535
536 # compute_importance_map takes long time when computing on cpu. We thus
537 # compute it once if it's static and then save it for future usage
538 self.roi_weight_map = None
539 try:
540 if cache_roi_weight_map and isinstance(roi_size, Sequence) and min(roi_size) > 0: # non-dynamic roi size
541 if device is None:
542 device = "cpu"
543 self.roi_weight_map = compute_importance_map(
544 ensure_tuple(self.roi_size), mode=mode, sigma_scale=sigma_scale, device=device
545 )
546 if cache_roi_weight_map and self.roi_weight_map is None:
547 warnings.warn("cache_roi_weight_map=True, but cache is not created. (dynamic roi_size?)")
548 except Exception as e:
549 raise RuntimeError(
550 f"roi size {self.roi_size}, mode={mode}, sigma_scale={sigma_scale}, device={device}\n"
551 "Seems to be OOM. Please try smaller patch size or mode='constant' instead of mode='gaussian'."
552 ) from e
553
554 def __call__(
555 self,

Callers

nothing calls this directly

Calls 5

BlendModeClass · 0.90
compute_importance_mapFunction · 0.90
ensure_tupleFunction · 0.90
minFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected