TissueQC v1.0.0: weights, config and model card
Browse filesFiles changed (3)
- README.mdAdded+74
- config.jsonAdded+31
- model.safetensorsAdded+3
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374---license: apache-2.0library_name: segmentation-models-pytorchpipeline_tag: image-segmentationtags: - histopathology - whole-slide-image - tissue-segmentation - quality-control - artifact-detection---
# TissueQC
TissueQC segments a histology tile into background, tissue and artifact in a single forward pass at 5x (2 µm/px). The same output gives a tissue mask with artifacts kept or a tissue mask with artifacts cut out, so a whole-slide pipeline can drop folds, ink, blur and debris without running a second model.
| Class | Index | Meaning ||---|---|---|| background | 0 | glass, area outside the slide, artifacts lying on bare glass || tissue | 1 | tissue, including natural holes enclosed by tissue once filled || artifact | 2 | artifact on tissue: tissue fold, ink, out-of-focus area, knife line, air bubble, debris |
The network is a U-Net with an EfficientNet-B0 encoder (4.5M parameters). The encoder was initialised from the Apache-2.0 ImageNet weights `timm/efficientnet_b0.ra_in1k`.
## Usage
```pythonimport json, torch, segmentation_models_pytorch as smpfrom huggingface_hub import hf_hub_downloadfrom safetensors.torch import load_file
repo = "JaumeLab/TissueQC"cfg = json.load(open(hf_hub_download(repo, "config.json")))model = smp.Unet(encoder_name=cfg["encoder_name"], encoder_weights=None, classes=cfg["num_classes"], decoder_channels=tuple(cfg["decoder_channels"]))model.load_state_dict(load_file(hf_hub_download(repo, "model.safetensors")))model.eval()
# tile: uint8 RGB array read at 2 µm/px, H and W multiples of 32 (512 x 512 recommended)x = torch.from_numpy(tile).permute(2, 0, 1)[None].float() / 255x = (x - torch.tensor(cfg["mean"]).view(1, 3, 1, 1)) / torch.tensor(cfg["std"]).view(1, 3, 1, 1)with torch.inference_mode(): classes = model(x).argmax(1)[0] # 0 background, 1 tissue, 2 artifact```
Read tiles at 2 µm/px (5x). The model was trained on 512 x 512 tiles and is fully convolutional.
## From class map to slide mask
The two masks are built from the stitched class map of the whole slide:
- **Default:** tissue plus artifact regions with at least 25 % of their border on tissue, with enclosed holes filled. Artifacts lying mostly on bare glass count as background.- **Artifacts removed:** the default mask with artifact regions cut out. Regions narrower than 24 µm or smaller than 0.005 mm² are kept as tissue, so thin cracks and specks do not fragment the mask.
A pixel is artifact when that class is the most likely one. A lower cut-off on the artifact probability finds more artifacts at the cost of more false positives.
## Performance
On held-out test tiles, tissue Dice is 0.98 and artifact-on-tissue Dice is 0.95. Through a whole-slide pipeline on 16 TCGA slides, TissueQC took 52 s against 190 s for the HEST tissue segmenter on one GPU, with artifact removal included at no extra cost.
## Training
TissueQC was trained on whole-slide images including TCGA and GTEx, with H&E and immunohistochemistry stains.
## Limitations
- Dense, dark tissue (cellular tumour, smooth muscle bundles, thick fat septa) is sometimes predicted as artifact.- In thyroid, the dark folded edges of colloid are often predicted as artifact.- Artifact boundaries tend to be drawn wider than the visible artifact.- The model has not been validated for diagnostic use.
## License
Apache-2.0.12345678910111213141516171819202122232425262728293031{ "architecture": "smp.Unet", "encoder_name": "tu-efficientnet_b0", "decoder_channels": [ 128, 64, 48, 32, 16 ], "classes": [ "background", "tissue", "artifact" ], "num_classes": 3, "mpp": 2.0, "magnification": 5, "input_size": 512, "mean": [ 0.485, 0.456, 0.406 ], "std": [ 0.229, 0.224, 0.225 ], "version": "1.0.0"}123version https://git-lfs.github.com/spec/v1oid sha256:c58976dc85049d249a81782e3f25a11110f45417929682f9d3de6d48f39a9532size 18082700README.mdAdded+74
config.jsonAdded+31
model.safetensorsAdded+3