FastSurferCNN.inference¶
- class FastSurferCNN.inference.Inference(cfg, device, ckpt='', lut=None)[source]¶
Model evaluation class to run inference using FastSurferCNN.
Attributes
permute_order
(Dict[str, Tuple[int, int, int, int]]) Permutation order for axial, coronal, and sagittal
device
(Optional[torch.device])) Device specification for distributed computation usage.
default_device
(torch.device) Default device specification for distributed computation usage.
cfg
(yacs.config.CfgNode) Configuration Node
model_parallel
(bool) Option for parallel run
model
(torch.nn.Module) Neural network model
model_name
(str) Name of the model
alpha
(Dict[str, float]) Alpha values for different planes.
post_prediction_mapping_hook
Hook for post prediction mapping.
Methods
setup_model
([cfg, device])Set up the model.
set_cfg
(cfg)Set the configuration node.
to
([device])Move and/or cast the parameters and buffers.
load_checkpoint
(ckpt)Load the checkpoint and set device and model.
eval
(init_pred, val_loader, *[, out_scale, out])Perform prediction and inplace-aggregate views into pred_prob.
run
(init_pred, img_filename, orig_data, ...)Run the loaded model on the data (T1) from orig_data and img_filename (for messages only) with scale factors orig_zoom.
- eval(init_pred, val_loader, *, out_scale=None, out=None)[source]¶
Perform prediction and inplace-aggregate views into pred_prob.
- Parameters:
- init_pred
torch.Tensor
Initial prediction.
- val_loader
DataLoader
Validation loader.
- out_scale
Optional
Output scale (Default value = None).
- out
Optional
[torch.Tensor
] Previous prediction tensor (Default value = None).
- init_pred
- Returns:
torch.Tensor
Prediction probability tensor.
- load_checkpoint(ckpt)[source]¶
Load the checkpoint and set device and model.
- Parameters:
- ckpt
Union
[str
,os.PathLike
] String or os.PathLike object containing the name to the checkpoint file.
- ckpt
- run(init_pred, img_filename, orig_data, orig_zoom, out=None, out_res=None, batch_size=None)[source]¶
Run the loaded model on the data (T1) from orig_data and img_filename (for messages only) with scale factors orig_zoom.
- Parameters:
- init_pred
torch.Tensor
Initial prediction.
- img_filename
str
Original image filename.
- orig_data
npt.NDArray
Original image data.
- orig_zoom
npt.NDArray
Original zoom.
- out
Optional
[torch.Tensor
] Updated output tensor (Default = None).
- out_res
Optional
[int
] Output resolution (Default value = None).
- batch_size
int
Batch size (Default = None).
- init_pred
- Returns:
toch.Tensor
Prediction probability tensor.
- set_cfg(cfg)[source]¶
Set the configuration node.
- Parameters:
- cfg
yacs.config.CfgNode
Configuration node.
- cfg