How prov-gigapath/prov-gigapath works
Prov-GigaPath is a computational pathology foundation-model toolkit. Its main inference workflow prepares whole-slide images as tiles, encodes each tile, then combines tile embeddings and coordinates into a slide representation; downstream tasks can use that representation for classification. The repository also provides cross-validation finetuning and preprocessing utilities. The README documents the workflow, while source excerpts and the SOURCE INDEX support selected implementation links; unsampled internals and some optional integrations are not expanded.
Main entry points: create_tiles_dataset.py Tile dataset creation · pipeline.py Inference pipeline · slide_encoder.py Slide encoder · main.py Finetune workflow
Components 21
Slide preprocessing
- Tile dataset creation
gigapath/preprocessing/data/create_tiles_dataset.py - Foreground segmentation
gigapath/preprocessing/data/foreground_segmentation.py - Slide tiling
gigapath/preprocessing/data/tiling.py - Image tiles
Model inference
- Inference pipeline
gigapath/pipeline.py - Tile encoder
gigapath/tile_encoder.py - Tile embeddings
- Slide encoder
gigapath/slide_encoder.py - Slide representation
Downstream tasks
- Classification head
gigapath/classification_head.py - Finetune workflow
finetune/main.py - Slide dataset
finetune/datasets/slide_datatset.py - Training and evaluation
finetune/training.py - Task metrics
finetune/metrics.py
Model internals
- LongNet backbone
gigapath/torchscale/model/LongNet.py - Transformer encoder
gigapath/torchscale/architecture/encoder.py - Dilated attention
gigapath/torchscale/component/multihead_attention.py - Expert layers
gigapath/torchscale/component/xmoe/moe_layer.py - Expert routing
gigapath/torchscale/component/xmoe/routing.py
Other components
- Pathology user
- Whole-slide images
Connections 23
- Pathology user → Whole-slide images: provides slides
README.md - Whole-slide images → Tile dataset creation: preprocesses
README.md - Tile dataset creation → Foreground segmentation: filters foreground
gigapath/preprocessing/data/create_tiles_dataset.py - Tile dataset creation → Slide tiling: creates tiles
gigapath/preprocessing/data/create_tiles_dataset.py - Tile dataset creation → Image tiles: writes tiles
gigapath/preprocessing/data/create_tiles_dataset.py - Whole-slide images → Inference pipeline: runs inference on
README.md - Inference pipeline → Tile dataset creation: invokes tiling
gigapath/pipeline.py - Inference pipeline → Tile encoder: loads encoder
gigapath/pipeline.py - Image tiles → Tile encoder: encodes tiles
README.md - Tile encoder → Tile embeddings: produces embeddings
README.md - Tile embeddings → Slide encoder: passes embeddings and coordinates
README.md - Slide encoder → Slide representation: produces representation
README.md - Slide encoder → LongNet backbone: builds backbone
gigapath/slide_encoder.py - LongNet backbone → Transformer encoder: constructs layers
gigapath/torchscale/model/LongNet.py - Transformer encoder → Dilated attention: uses attention
gigapath/torchscale/architecture/encoder.py - Transformer encoder → Expert layers: uses expert layers
gigapath/torchscale/architecture/encoder.py - Expert layers → Expert routing: routes tokens
gigapath/torchscale/component/xmoe/routing.py - Slide representation → Classification head: classifies
gigapath/classification_head.py - Pathology user → Finetune workflow: configures task
README.md - Finetune workflow → Slide dataset: builds datasets
finetune/main.py - Finetune workflow → Training and evaluation: starts training
finetune/main.py - Training and evaluation → Classification head: trains model
finetune/training.py - Training and evaluation → Task metrics: computes metrics
finetune/training.py