Skip to content

owkin/owkin-gigatime

 
 

Repository files navigation

GigaTIME — Owkin Fork

Owkin's fork of the original GigaTIME repository (Microsoft Research / Providence). The original code is preserved under legacy_gigatime_repo/. This fork repackages the model as a clean Python library aimed at running inference on Owkin's platforms.

Paper: GigaTIME: Multimodal AI generates virtual population for tumor microenvironment modelingCell Model weights: prov-gigatime/GigaTIME on HuggingFace (access requires accepting the terms of use)


What GigaTIME does

GigaTIME takes a standard H&E tile and predicts 23 virtual multiplexed immunofluorescence (mIF) channels — including CD3, CD8, CD4, CD68, PD-L1, Ki67, and CK — using a UNet++ architecture trained on the HE-COMET dataset.

Input requirements: 512×512 px RGB tiles at ~20x magnification (0.5 µm/px).


Setup

Requires uv.

uv sync                    # inference only
uv sync --extra train      # + training dependencies
uv sync --extra notebooks  # + Jupyter

Store your HuggingFace token in .hf_token (already gitignored) and export it before running:

echo "hf_..." > .hf_token
export HF_TOKEN=$(cat .hf_token)

Usage

As a library

from gigatime.inference import load_model, predict
from gigatime.data import SlideReader, iter_tiles, stitch

# Load model (downloads weights from HuggingFace if no path given)
model = load_model(device="cuda")

# Open a WSI — resolution is handled automatically
results = []
with SlideReader("path/to/slide.svs") as reader:
    for tile, grid in iter_tiles(reader, tile_size=512, overlap=32, min_tissue_fraction=0.1):
        pred = predict(tile.array, model, device="cuda")
        results.append((pred, tile))

# Reassemble a slide-level prediction map
cd8_map = stitch(results, grid, channel="CD8", mode="mean")  # (H, W) float32

From S3

from gigatime.data import list_slides, download_slide

uris = list_slides("my-bucket", prefix="cohort/slides/")
local_path = download_slide(uris[0], dest_dir="/tmp/slides")

CLI

uv run gigatime-infer \
  --input tiles/ \
  --output_dir ./results \
  --device cuda \
  --overlap 32

Notebook

An end-to-end example running inference on TCGA-LUAD slides is at notebooks/inference_tcga_luad.py.


Repository structure

gigatime/                   # main Python package
├── inference/
│   ├── model.py            # GigaTIME architecture + weight loading
│   ├── predict.py          # inference logic (sliding window)
│   ├── constants.py        # channel names, tile size, normalisation
│   └── cli.py              # command-line interface
├── data/
│   ├── s3.py               # S3 slide discovery and download
│   ├── slide.py            # OpenSlide wrapper (auto level selection)
│   ├── tiling.py           # tile iterator and slide-level stitching
│   └── paths.py            # dataset path constants
└── features/
    ├── compartments.py     # tumour / stroma masks from CK + DAPI
    ├── coexpression.py     # pixel-level and cell-footprint co-expression
    ├── density.py          # compartment-normalised density
    ├── proximity.py        # distance-transform spatial proximity scores
    ├── tls.py              # tertiary lymphoid structure detection
    ├── features.py         # assembles all features into a flat dict per slide
    └── README.md           # feature catalogue with biomedical questions
notebooks/                  # worked examples
legacy_gigatime_repo/       # original Microsoft / Providence code (unmodified)
pyproject.toml              # uv-managed dependencies

Output channels

Index Channel Notes
0 DAPI Nuclear stain
1 TRITC Background — excluded from analysis
2 Cy5 Background — excluded from analysis
3–22 PD-1, CD14, CD4, T-bet, CD34, CD68, CD16, CD11c, CD138, CD20, CD3, CD8, PD-L1, CK, Ki67, Tryptase, Actin-D, Caspase3-D, PHH3-B, Transgelin

License

Model weights and original code are subject to the original research-only license. This fork inherits the same terms.

About

Fork of GigaTIME: Multimodal AI generates virtual population for tumor microenvironment modeling (Cell)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

No contributors

Languages

  • Jupyter Notebook 87.2%
  • Python 12.5%
  • Makefile 0.3%