[78ef36]: / docs-source / source / mil_module.rst

Download this file

103 lines (79 with data), 4.3 kB

slideflow.mil

This submodule contains tools for multiple-instance learning (MIL) model training and evaluation. See :ref:`mil` for more information. A summary of the API is given below.

Training:
  • :func:`train_mil()`: Train an MIL model, using an MIL configuration, Datasets, and a directory of bags.
  • :func:`build_fastai_learner()`: Build and return the FastAI Learner, but do not execute training. Useful for customizing training.
  • :func:`build_multimodal_learner()`: Build and return a FastAI Learner designed for multi-modal/multi-magnification input.
Evaluation/Inference:
  • :func:`eval_mil()`: Evaluate an MIL model using a path to a saved model, a Dataset, and path to bags. Generates metrics.
  • :func:`predict_mil()`: Generate predictions from an MIL model and saved bags. Returns a pandas dataframe.
  • :func:`predict_multimodal_mil()`: Generate predictions from a multimodal MIL model. Returns a dataframe.
  • :func:`predict_slide()`: Generate MIL predictions for a single slide. Returns a 2D array of predictions and attention.
  • :func:`predict_from_bags()`: Low-level interface for generating predictions from a loaded MIL model and pre-loaded bag Tensors.
  • :func:`predict_from_multimodal_bags()`: Low-level interface for generating multimodal predictions from a loaded MIL model and bag Tensors.
  • :func:`get_mil_tile_predictions()`: Get tile-level predictions and attention from a saved MIL model for a given Dataset and saved bags.
  • :func:`generate_attention_heatmaps()`: Generate and save attention heatmaps.
  • :func:`generate_mil_features()`: Get last-layer activations from an MIL model. Returns an MILFeatures object.

Main functions

TrainerConfig

MILModelConfig

CLAMModelConfig

The CLAM model configuration class requires slideflow-gpl, which can be installed with:

pip install slideflow-gpl

Once installed, the class is available at slideflow.clam.CLAMModelConfig.