|
Download README.md from soroush-oskouei/tissue_segmentation: direct link, hf CLI and curl.
- Browser
- Download file 3.97 kB
-
https://huggingface.co/soroush-oskouei/tissue_segmentation/resolve/main/README.md
- Command line
-
hf download hf://soroush-oskouei/tissue_segmentation/README.md
-
curl -L -o README.md https://huggingface.co/soroush-oskouei/tissue_segmentation/resolve/main/README.md
3.97 kB
| license: mit | |
| library_name: pytorch | |
| pipeline_tag: image-segmentation | |
| tags: | |
| - histopathology | |
| - whole-slide-image | |
| - tissue-segmentation | |
| - pathology | |
| - unet | |
| - densenet121 | |
| - mobilenetv2 | |
| - medical-imaging | |
| - tcga | |
| # FusionUNet — Whole Slide Image (WSI) Tissue Segmentation | |
| **FusionUNet** is a dual-encoder semantic segmentation model designed for automated tissue foreground segmentation in brightfield histopathology Whole Slide Images (WSIs). The architecture combines **DenseNet-121** and **MobileNetV2** feature extractors via gated feature fusion modules and concurrent spatial-and-channel Squeeze-and-Excitation (**scSE**) attention blocks. | |
| ## Sample Result | |
|  | |
| --- | |
| ## Model Details | |
| - **Repository:** [soroush-oskouei/tissue_segmentation](https://huggingface.co/soroush-oskouei/tissue_segmentation) | |
| - **Architecture:** Dual-encoder U-Net (`FusionUNet`) with DenseNet-121 + MobileNetV2 backbones, gated multi-scale fusion, and scSE attention in both fusion and decoder stages. | |
| - **Input:** RGB histopathology image tiles normalized using checkpoint channel statistics (`mean` and `std`), resolution (`500 × 500` px). | |
| - **Output:** Single-channel logit map converted via sigmoid activation into tissue foreground probabilities (`[0, 1]`). | |
| - **Checkpoint Contents (`best_fusion_unet.pt`):** | |
| - `model_state`: Trained PyTorch `state_dict` | |
| - `model_kwargs`: Architecture hyperparameters (`num_classes`, `fused_ch`, `dec_ch`) | |
| - `img_size`: Training tile resolution | |
| - `mean` / `std`: Channel normalization parameters | |
| - `threshold`: Optimal validation probability threshold | |
| - `epoch` & validation score (`val_dice` / `val_f1`) | |
| --- | |
| ## Quickstart & Usage | |
| ### 1. Clone the Inference Repository & Install Dependencies | |
| ```bash | |
| git clone [https://github.com/SoroushOskouei/tissue-segmentation.git](https://github.com/SoroushOskouei/tissue-segmentation.git) | |
| cd tissue-segmentation | |
| pip install torch torchvision numpy opencv-python matplotlib tqdm openslide-python openslide-bin huggingface_hub | |
| ``` | |
| ### 2. Download Model Weights from Hugging Face | |
| Using the Python API: | |
| ```python | |
| from huggingface_hub import hf_hub_download | |
| ckpt_path = hf_hub_download( | |
| repo_id="soroush-oskouei/tissue_segmentation", | |
| filename="best_fusion_unet.pt", | |
| local_dir="weights", | |
| ) | |
| print("Downloaded checkpoint to:", ckpt_path) | |
| ``` | |
| Or via the Hugging Face CLI: | |
| ```bash | |
| hf download soroush-oskouei/tissue_segmentation best_fusion_unet.pt --local-dir weights | |
| ``` | |
| ### 3. Run Whole Slide Image Inference | |
| ```bash | |
| python infer.py \ | |
| --wsi path/to/slide.svs \ | |
| --checkpoint weights/best_fusion_unet.pt \ | |
| --out-dir results/ | |
| ``` | |
| To test the pipeline on a public Aperio sample slide (`CMU-1.svs`): | |
| ```bash | |
| python infer.py \ | |
| --download-sample \ | |
| --checkpoint weights/best_fusion_unet.pt \ | |
| --out-dir results/ | |
| ``` | |
| ### Generated Outputs | |
| For each input slide, the inference script exports: | |
| - `*_mask.png` — Post-processed binary tissue mask at target MPP. | |
| - `*_prob.png` — Blended tissue probability map (`0–255`). | |
| - `*_overlay.jpg` — Slide thumbnail with semi-transparent mask overlay and tissue contours. | |
| - `*_tissue.geojson` — Polygon annotations with hole support in level-0 coordinates (compatible with **QuPath**). | |
| - `*_summary.png` — 4-panel visual summary (Thumbnail, Probability, Mask, Overlay). | |
| - `*_info.json` — Slide metadata, inference settings, runtime, and total tissue area ($\text{mm}^2$). | |
| --- | |
| ## Training Data & Acknowledgments | |
| The training and validation datasets used to develop these weights were derived from **The Cancer Genome Atlas (TCGA)** Research Network ([https://www.cancer.gov/tcga](https://www.cancer.gov/tcga)). We gratefully acknowledge the TCGA consortium, tissue donors, and contributing clinical institutions for making these histopathology whole slide images publicly available. | |
| --- | |