StrokeSegLab
Loading...
Searching...
No Matches
StrokeSegLab.inference.inference.Inference Class Reference

Public Member Functions

None __init__ (self, gui=None)
 
np.ndarray run (self, np.ndarray data)
 

Public Attributes

 logger = logging.getLogger()
 
str device = option.get("device")
 
 gui = gui
 
 config = Config()
 
 model_path = option.get("model_path")
 
list patch_size = [128,128,128]
 
list model_path = [self.device]
 
 ort_session = ort.InferenceSession(self.model_path, providers=providers)
 

Protected Member Functions

list[list[int]] _compute_steps (self, tuple[int, int, int] image_size, list[int] patch_size, float step_size=0.5)
 
np.ndarray _compute_gaussian (self, list[int] patch_size, dtype=np.float32, float sigma_scale=1./8, float value_scaling_factor=10.0)
 

Detailed Description

This class performs inference on 3D images using an ONNX model

Constructor & Destructor Documentation

◆ __init__()

None StrokeSegLab.inference.inference.Inference.__init__ ( self,
gui = None )
Initialize the inference:
- Setup de Config and Option class
- Call for update_models to update the models list
- Preload CUDA DLLs to avoid runtime errors when using the CUDAExecutionProvider
Args:
    gui (GUIMain, optional): _description_. Defaults to None.

Member Function Documentation

◆ _compute_gaussian()

np.ndarray StrokeSegLab.inference.inference.Inference._compute_gaussian ( self,
list[int] patch_size,
dtype = np.float32,
float sigma_scale = 1./8,
float value_scaling_factor = 10.0 )
protected
@public
Compute a centered Gaussian importance map for a patch size
Args:
    patch_size (list[int]): Dimensions of the patch
    dtype (_type_, optional): Data type of the resulting map. Defaults to np.float32
    sigma_scale (float, optional): Scale factor for the standard deviation of the Gaussian. Defaults to 1./8
    value_scaling_factor (float, optional): Value used to normalize the max of the map. Defaults to 10.0

Returns:
    np.ndarray: Gaussian importance map

◆ _compute_steps()

list[list[int]] StrokeSegLab.inference.inference.Inference._compute_steps ( self,
tuple[int,int,int] image_size,
list[int] patch_size,
float step_size = 0.5 )
protected
@public
Compute the coordinates of starting positions for the inference
Args:
    image_size (tuple[int,int,int]): Size of the image
    patch_size (list[int]): Size of the patch to extract
    step_size (float, optional): Controls the overlap between consecutive patches. Defaults to 0.5

Returns:
    list[list[int]]: A list of three lists, each containing the start positions for the sliding window in the x, y, and z dimensions

◆ run()

np.ndarray StrokeSegLab.inference.inference.Inference.run ( self,
np.ndarray data )
Run the inference on a 4D input using a ONNX model
Args:
    data (np.ndarray): Input 4D volume. Shape : (1, x, y, z) for one channel model and (2, x, y, z) for T1/FLAIR model

Returns:
    np.ndarray: Output prediction volume. Shape : (b, c, x, y, z), b : batch size, c : output class (2 = background and lesion)

The documentation for this class was generated from the following file: