jamesdolezal / slideflow

Deep learning library for digital pathology, with both Tensorflow and PyTorch support.
https://slideflow.dev
GNU General Public License v3.0
234 stars 39 forks source link

Version 2.2.0 #329

Closed jamesdolezal closed 8 months ago

jamesdolezal commented 8 months ago

Highlights

Slideflow 2.2 further extends multiple-instance learning (MIL) capabilities, with the introduction of multi-magnification MIL, new models, experimental uncertainty quantification, and various other enhancements. This release also includes two new pretrained feature extractors - HistoSSL and PLIP - as well as support for the self-supervised learning framework, DINOv2. Slideflow Studio has been updated with several new features and quality of life improvements. Finally, the documentation has been enriched with Developer Notes and new tutorials, providing deeper insights on select topics.

Table of Contents

  1. Multi-Magnification MIL
  2. New Feature Extractors a. Pretrained b. DINOv2
  3. New MIL Features
  4. Slideflow Studio Updates
  5. Documentation Expansion
  6. Other New Features
  7. Version Requirements

Multi-Magnification MIL

Slideflow now supports multi-modal MIL, with feature bags generated from multiple feature extractors at different magnifications. Multi-magnification MIL offers potential advantages if there are valuable histologic features at both low and high magnification.

Working with multi-magnification MIL is easy - you can use the same training API as standard MIL models. Simply provide multiple bag paths (one for each magnification) and use the new "mm_attention_mil" model.

# Configure a multimodal MIL model.
config = mil_config('mm_attention_mil', lr=1e-4)

# Set the bags paths for each modality.
bags_10x = '/path/to/bags_10x'
bags_40x = '/path/to/bags_40x'

P.train_mil(
    config=config,
    outcomes='HPV_status',
    train_dataset=train,
    val_dataset=val,
    bags=[bags_10x, bags_40x]
)

Slideflow Studio also supports multi-magnification MIL models, allowing you to visualize attention and tile-level predictions from each mode separately.

New Feature Extractors

We've introduced support for two new pretrained feature extractors, as well as the self-supervised learning framework DINOv2.

Pretrained

The new pretrained feature extractors include:

Licenses and citations are available for all feature extractors through the new .license and .citation attributes.

>>> ctranspath = sf.model.build_feature_extractor('ctranspath', tile_px=299)
>>> ctranspath.license
'GNU General Public License v3.0'
>>> print(ctranspath.citation)

@{wang2022,
  title={Transformer-based Unsupervised Contrastive Learning for Histopathological Image Classification},
  author={Wang, Xiyue and Yang, Sen and Zhang, Jun and Wang, Minghui and Zhang, Jing  and Yang, Wei and Huang, Junzhou  and Han, Xiao},
  journal={Medical Image Analysis},
  year={2022},
  publisher={Elsevier}
}

DINOv2

As with SimCLR, Slideflow now supports generating features from a trained DINOv2 model. Use the feature extractor 'dinov2', and pass the *.pth teacher weights to the argument weights, and the YAML configuration file to the argument cfg:

dinov2 = sf.model.build_feature_extractor(
  'dinov2',
  weights='/path/to/teacher_checkpoint.pth',
  cfg='/path/to/config.yaml'

We've also provided a modified version of DINOv2 that allows you to train the network using Slideflow projects and datasets. See our documentation for instructions on how to train and use DINOv2.

New MIL Features

Slideflow 2.2 includes a number of updates in MIL functionality, including:

Slideflow Studio Updates

The latest version of Slideflow Studio includes a number of usability improvements and new features.

Documentation Expansion

Documentation at https://slideflow.dev has been further expanded, and a new Developer Notes section has been added. Developer Notes are intended to provide a deeper dive into selected topics of interest for developers or advanced users. Our first developer notes include:

In addition to these new Dev Notes, we've also added two tutorials (Tutorial 7: Training with Custom Augmentations and Tutorial 8: Multiple-Instance Learning), as well as expanded our Slideflow Studio docs to reflect the latest features.

Other New Features

Version Requirements

Version requirements are largely unchanged. Notable differences include: