Vision inference


source

save_series_pred


def save_series_pred(
    series_obj, save_dir, val:str='1234'
):

Saves series prediction with updated DICOM UIDs.


source

load_system_resources


def load_system_resources(
    models_path, learner_fn, variables_fn
):

Load necessary resources like learner and variables.


source

inference


def inference(
    learn_inf, apply_reorder, target_spacing, fn:(<class 'str'>, <class 'pathlib.Path'>)='',
    save_path:(<class 'str'>, <class 'pathlib.Path'>)=None, org_img:NoneType=None, input_img:NoneType=None,
    org_size:NoneType=None
):

Predict on new data using exported model.


source

compute_binary_tumor_volume


def compute_binary_tumor_volume(
    mask_data:Image
):

Compute the volume of the tumor in milliliters (ml).

Post-processing


source

refine_binary_pred_mask


def refine_binary_pred_mask(
    pred_mask, remove_size:(<class 'int'>, <class 'float'>)=None, percentage:float=0.2, verbose:bool=False
)->Tensor:

Removes small objects from the predicted binary mask.

Args: pred_mask: The predicted mask from which small objects are to be removed. remove_size: The size under which objects are considered ‘small’. percentage: The percentage of the remove_size to be used as threshold. Defaults to 0.2. verbose: If True, print the number of components. Defaults to False.

Returns: The processed mask with small objects removed.


source

keep_largest


def keep_largest(
    pred_mask:Tensor
)->Tensor:

Keep only the largest connected component in a binary mask.

Args: pred_mask: Binary prediction mask tensor.

Returns: Binary mask with only the largest connected component.

Gradio


source

gradio_image_classifier


def gradio_image_classifier(
    file_obj, learn, apply_reorder, target_spacing
):

Predict on images using exported learner and return the result as a dictionary.