monailabel.interfaces.app module

class monailabel.interfaces.app.MONAILabelApp(app_dir, studies, conf, name='', description='', version='2.0', labels=None)[source]

Bases: object

Default Pre-trained Path for downloading models

Base Class for Any MONAI Label App

Parameters
  • app_dir (str) – path for your App directory

  • studies (str) – path for studies/datalist

  • conf (Dict[str, str]) – dictionary of key/value pairs provided by user while running the app

PRE_TRAINED_PATH: str = 'https://github.com/Project-MONAI/MONAILabel/releases/download/data'
__init__(app_dir, studies, conf, name='', description='', version='2.0', labels=None)[source]

Base Class for Any MONAI Label App

Parameters
  • app_dir (str) – path for your App directory

  • studies (str) – path for studies/datalist

  • conf (Dict[str, str]) – dictionary of key/value pairs provided by user while running the app

async_batch_infer(model, images, params=None)[source]
async_scoring(method, params=None)[source]
async_training(model, params=None, enqueue=False)[source]
batch_infer(request, datastore=None)[source]

Run batch inference for an existing pre-trained model.

Parameters
  • request – JSON object which contains model, params and device

  • datastore

    Datastore object. If None then use default app level datastore to fetch the images

    For example:

    {
        "device": "cuda"
        "model": "segmentation_spleen",
        "images": "unlabeled",
        "label_tag": "original"
    }
    

Raises

MONAILabelException – When model is not found

Returns

JSON containing label and params

bundle_path(model)[source]
cleanup_sessions()[source]
datastore()[source]
Return type

Datastore

infer(request, datastore=None)[source]

Run Inference for an exiting pre-trained model.

Parameters
  • request – JSON object which contains model, image, params and device

  • datastore

    Datastore object. If None then use default app level datastore to save labels if applicable

    For example:

    {
        "device": "cuda"
        "model": "segmentation_spleen",
        "image": "file://xyz",
        "save_label": "true/false",
        "label_tag": "original"
    }
    

Raises

MONAILabelException – When model is not found

Returns

JSON containing label and params

infer_wsi(request, datastore=None)[source]
info()[source]

Provide basic information about APP. This information is passed to client.

init_batch_infer()[source]
Return type

Callable

init_datastore()[source]
Return type

Datastore

init_infers()[source]
Return type

Dict[str, InferTask]

init_remote_datastore()[source]
Return type

Datastore

init_scoring_methods()[source]
Return type

Dict[str, ScoringMethod]

init_strategies()[source]
Return type

Dict[str, Strategy]

init_trainers()[source]
Return type

Dict[str, TrainTask]

model_file(model, validate=True)[source]
model_info(model)[source]
next_sample(request)[source]

Run Active Learning selection. User APP has to implement this method to provide next sample for labelling.

Parameters

request

JSON object which contains active learning configs that are part APP info

For example:

{
    "strategy": "random"
}

Returns

JSON containing next image info that is selected for labeling

on_init_complete()[source]
on_save_label(image_id, label_id)[source]

Callback method when label is saved into datastore by a remote client

scoring(request, datastore=None)[source]

Run scoring task over labels.

Parameters
  • request – JSON object which contains model, params and device

  • datastore

    Datastore object. If None then use default app level datastore to fetch the images

    For example:

    {
        "device": "cuda"
        "method": "dice",
        "y": "final",
        "y_pred": "original",
    }
    

Raises

MONAILabelException – When method is not found

Returns

JSON containing result of scoring method

server_mode(mode)[source]
sessions()[source]
train(request)[source]

Run Training. User APP has to implement this method to run training

Parameters

request

JSON object which contains train configs that are part APP info

For example:

{
    "model": "mytrain",
    "device": "cuda"
    "max_epochs": 1,
}

Returns

JSON containing train stats