Commit
·
39df7e9
1
Parent(s):
2fad864
docs: update tool name
Browse files
README.md
CHANGED
|
@@ -13,7 +13,7 @@ tags:
|
|
| 13 |
|
| 14 |
# AtlasPatch: Whole-Slide Image Tissue Segmentation
|
| 15 |
|
| 16 |
-
Segmentation model for whole-slide image (WSI) thumbnails, built on **Segment Anything 2 (SAM2) Tiny** and finetuned only on the normalization layers. The model takes a **power-based WSI thumbnail
|
| 17 |
|
| 18 |
## Quickstart
|
| 19 |
|
|
@@ -23,7 +23,7 @@ Install dependencies:
|
|
| 23 |
pip install atlas-patch
|
| 24 |
```
|
| 25 |
|
| 26 |
-
Recommended: use the same components we ship in AtlasPatch
|
| 27 |
|
| 28 |
```python
|
| 29 |
import numpy as np
|
|
@@ -32,14 +32,14 @@ from pathlib import Path
|
|
| 32 |
from PIL import Image
|
| 33 |
from importlib.resources import files
|
| 34 |
|
| 35 |
-
from
|
| 36 |
-
from
|
| 37 |
-
from
|
| 38 |
|
| 39 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 40 |
|
| 41 |
# 1) Config: packaged SAM2 Hiera-T config; leave checkpoint_path=None to auto-download from HF.
|
| 42 |
-
cfg_path = Path(files("
|
| 43 |
seg_cfg = SegmentationConfig(
|
| 44 |
checkpoint_path=None, # downloads Atlas-Patch/model.pth from Hugging Face
|
| 45 |
config_path=cfg_path,
|
|
@@ -65,7 +65,7 @@ mask_img.save("thumbnail_mask.png")
|
|
| 65 |
AtlasPatch generates thumbnails at **1.25× objective power** (power-based downsampling) and then clamps the longest side to **1024 px**. Using the same helper the library uses:
|
| 66 |
|
| 67 |
```python
|
| 68 |
-
from
|
| 69 |
|
| 70 |
wsi = WSIFactory.load("slide.svs")
|
| 71 |
thumb = wsi.get_thumbnail_at_power(power=1.25, interpolation="optimise")
|
|
|
|
| 13 |
|
| 14 |
# AtlasPatch: Whole-Slide Image Tissue Segmentation
|
| 15 |
|
| 16 |
+
Segmentation model for whole-slide image (WSI) thumbnails, built on **Segment Anything 2 (SAM2) Tiny** and finetuned only on the normalization layers. The model takes a **power-based WSI thumbnail at 1.25x magnification level (resized to 1024×1024)** and predicts a binary tissue mask. Training used segmented thumbnails. AtlasPatch codebase (WSI preprocessing & tooling): https://github.com/AtlasAnalyticsLab/AtlasPatch
|
| 17 |
|
| 18 |
## Quickstart
|
| 19 |
|
|
|
|
| 23 |
pip install atlas-patch
|
| 24 |
```
|
| 25 |
|
| 26 |
+
Recommended: use the same components we ship in AtlasPatch. The segmentation service will (a) load your WSI with the registered backend, (b) build a 1.25× power thumbnail, (c) resize it to 1024×1024, (d) run SAM2 with a full-frame box, and (e) return a mask aligned to the thumbnail.
|
| 27 |
|
| 28 |
```python
|
| 29 |
import numpy as np
|
|
|
|
| 32 |
from PIL import Image
|
| 33 |
from importlib.resources import files
|
| 34 |
|
| 35 |
+
from atlas_patch.core.config import SegmentationConfig
|
| 36 |
+
from atlas_patch.services.segmentation import SAM2SegmentationService
|
| 37 |
+
from atlas_patch.core.wsi import WSIFactory
|
| 38 |
|
| 39 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 40 |
|
| 41 |
# 1) Config: packaged SAM2 Hiera-T config; leave checkpoint_path=None to auto-download from HF.
|
| 42 |
+
cfg_path = Path(files("atlas_patch.configs") / "sam2.1_hiera_t.yaml")
|
| 43 |
seg_cfg = SegmentationConfig(
|
| 44 |
checkpoint_path=None, # downloads Atlas-Patch/model.pth from Hugging Face
|
| 45 |
config_path=cfg_path,
|
|
|
|
| 65 |
AtlasPatch generates thumbnails at **1.25× objective power** (power-based downsampling) and then clamps the longest side to **1024 px**. Using the same helper the library uses:
|
| 66 |
|
| 67 |
```python
|
| 68 |
+
from atlas_patch.core.wsi import WSIFactory
|
| 69 |
|
| 70 |
wsi = WSIFactory.load("slide.svs")
|
| 71 |
thumb = wsi.get_thumbnail_at_power(power=1.25, interpolation="optimise")
|