transformers onnx safetensors license:cc-by-4.0 endpoints_compatible region:us
---
license: cc-by-4.0
---
# Metastasis classification (CAMELYON16)

This model classifies an H&E-stained digital pathology image of axillary lymph nodes as not containing metastasis or containing metastasis. It was trained by Jakub Kaczmarzyk.

Inputs: Bag of patches with 128um edge length, embedded with CTransPath.

Output classes: no-metastasis, metastasis

## Data

CAMELYON16 was used to train the model. The whole slide images were tiled into 128x128um patches, and each patch was encoded using CTransPath (this produces 768-dimensional embeddings).

Train and validation splits were stratified by metastasis status. The test set is pre-defined in the CAMELYON16 dataset.

Samples sizes:
- Train: 243 slides
- Validation: 27 slides
- Test: 129 slides

## Reusing this model

To use this model on the command line, see [WSInfer-MIL](https://github.com/kaczmarj/wsinfer-mil).

Alternatively, you may use PyTorch on ONNX to run the model. First, embed 128um x 128um patches using CTransPath. Then pass the bag of embeddings to the model.

```python
import onnxruntime as ort
import numpy as np
embedding = np.ones((1_000, 768), dtype="float32")
ort_sess = ort.InferenceSession("model.onnx")
logits, attention = ort_sess.run(["logits", "attention"], {'input': embedding})
```

## Model performance

The model achieves an AUC of 0.91 in the test set of CAMELYON16. Below, please find a confusion matrix, where predicted classes are columns, and true values are rows.

|        | No-Met | Met |
|--------|--------|-----|
| No-Met | 77     | 3   |
| Met    | 12     | 37  |

# Intended uses

This model is ONLY intended for research purposes.

**This model may not be used for clinical purposes.** This model is distributed without warranties, either express or implied.
