UBC-OCEAN

Kaggle, solo, three months

Oct 2023 – Jan 2024

A three-month solo run at the UBC Ovarian Cancer Subtype Classification (UBC-OCEAN) Kaggle competition. The task: look at a microscope scan of a biopsy and predict which of five ovarian cancer subtypes it is, while also flagging images that don't fit any known subtype as "Other". I finished 28th of 1,724, silver medal. Code is on GitHub.

Why it was tricky. The images come in two very different formats. Whole-slide images (WSI) are enormous scans of an entire tissue slide at 20x magnification, often around 50,000 × 50,000 pixels and mostly non-tumor area. Tissue microarrays (TMA) are small cores the pathologist has already punched out of a WSI and scanned at 40x, usually around 4,000 × 4,000 pixels and almost entirely tumor. The train set is mostly WSIs with only 25 TMAs, but the test set is mostly TMAs. The "Other" class never appears in training at all.

My approach: the "classic" path. A fine-tuned CNN classifier, with a separate tumor detector for WSIs.

  • Only 25 TMAs in training, so I mined tumor-heavy tiles out of the WSIs (using the organizers' supplemental tumor masks) and used them as TMA-like training samples: >70% tumor pixels for training, 30-70% for validation.
  • Fine-tuned maxvit_tiny_tf_512 on those tiles to predict the subtype.
  • TMA inference: tile into 512×512 patches, classify each, majority-vote the final subtype.
  • WSI inference: a smaller tumor/non-tumor classifier runs first on downsized thumbnails. No-tumor thumbnails get labeled "Other"; tumor thumbnails feed the main classifier and majority-vote.
  • StainNet color normalization (popular for cross-hospital pathology generalization) underperformed simple normalization and was dropped.

Inference flow: an input slide is routed by type, TMA goes straight to tiling and the TMA model, WSI first passes a thumbnail tumor classifier which routes no-tumor thumbnails to

Inference pipeline for my 28th-place UBC-OCEAN solution.

Full writeup on Kaggle.

What the top solutions did differently. Most winning teams framed this as a Multiple Instance Learning (MIL) problem instead. The idea: a slide is a "bag of patches", and the model learns to pick which patches matter. Nobody fine-tunes a classifier on pixels. You run a frozen pathology foundation model (a big ViT pretrained with self-supervision on millions of pathology tiles) to turn each patch into a fixed-size feature vector, then train a cheap MIL classifier on top of those vectors. Since the foundation model already knows what pathology looks like, the classifiers on top can stay tiny and iterate fast.

1st place, Owkin:

  • Phikon, Owkin's pathology ViT-Base (iBOT-pretrained on 40M TCGA tiles), pre-computed a 768-dim embedding per patch once.
  • Ensemble of 50 Chowder MIL models (Owkin's own MIL architecture). Chowder is sensitive to initialization; ensembling was the stabilizer.
  • Outlier detection: a threshold on the entropy of ensemble predictions. High entropy (the ensemble disagreed) got labeled "Other". One line of code, took their public-LB score from 0.59 to 0.64.
  • Extra bump: further iBOT-fine-tuned Phikon on the competition's own patches.

Owkin's 1st place pipeline for UBC-OCEAN: WSI or TMA to matter detection, tiling, Phikon feature extraction, Chowder MIL, final cancer subtype, with high-entropy predictions routed to

Pipeline diagram from Owkin's 1st-place writeup.

7th place, m1dsolo:

  • Same recipe (frozen pathology backbone + MIL on top), different cast.
  • Two feature extractors: CTransPath (pathology-specific Swin Transformer, MIA 2022) and a ViT-S/16 pretrained on pathology with LunitDINO (CVPR 2023).
  • Two MIL models: DSMIL (Dual-Stream MIL, CVPR 2021) and Perceiver (from DualQueryMIL, BMVA 2023).
  • Final ensemble of 4 combinations: {CTransPath, ViT-S/16} × {DSMIL, Perceiver}.

Lessons I took from this:

  • Do more research when the domain is unfamiliar to you. I jumped into modeling before really understanding how pathologists work or how the WSI literature usually frames these problems. I paid for that in wasted cycles.
  • Mid-competition leaderboard position doesn't mean much. I was doing well for a stretch, but the private test set was built specifically to catch models that don't generalize. You don't win by being high at week 4, you win by being high when the competition ends.
  • Don't be afraid to try new approaches from recent papers. A lot of the top solutions used methods from papers published only a few months before the competition. I played conservatively and lost ground because of it.
  • First time handling huge images. A single WSI can be 100,000 × 50,000 pixels. You don't load them, you tile and stream them (libpng row-reads, pyvips, custom tiling code). PIL is not the answer.
  • First time with medical imaging. Staining differs between hospitals, scanners vary, metadata like magnification sometimes gets stripped during format conversion, the same cancer can look different under two different setups. None of that was in my vocabulary when I started.

Concepts I picked up:

  • Bag of patches. Instead of feeding a whole image to the model, chop it into small tiles (say 224×224) and treat the image as an unordered "bag" of those tiles. The label belongs to the bag, not to any individual tile.
  • Multiple Instance Learning (MIL). The learning setup built for exactly the bag-of-patches case: the model receives an unordered set of feature vectors and predicts one label for the whole bag. It learns which patches to pay attention to. Chowder, DSMIL, and Perceiver (all used by the winners here) are MIL architectures.

Takeaways I'm still thinking about:

  • Domain-specific foundation models change the shape of the problem. My ImageNet-pretrained backbone had to learn pathology from scratch. A frozen Phikon or CTransPath embedding is already most of the way there.
  • Pre-compute embeddings once, iterate cheaply on classifiers. Most of my three months went into fine-tuning a backbone; the winners spent theirs on modeling choices over frozen features.
  • MIL beats my hand-engineered tumor gate for WSIs. Letting the model pick which patches matter is cleaner than coding a thumbnail classifier.
  • Entropy-based outlier detection generalizes better than my thumbnail-gate heuristic, and it's simpler.
  • Next time I touch this kind of problem, I'd start with a pathology foundation model + MIL + ensemble before writing a single line of fine-tuning code.