WESUP
Source code for *Weakly Supervised Histopathology Image Segmentation with Sparse Point Annotations*.
Install / Use
/learn @mrcfps/WESUPREADME
WESUP
Source code for our paper Weakly Supervised Histopathology Image Segmentation with Sparse Point Annotations.
Data Preparation
MICCAI 2015 Gland Segmentation (GlaS)
GlaS challenge is a well-known H&E stained digital pathology dataset for medical image segmentation. Download the dataset from here. Then run the following convenience script to organize the dataset:
$ python prepare_glas.py /path/to/downloaded/dataset -o data_glas
The mask-level fully-annotated dataset data_glas looks like this:
data_glas
├── train
│ ├── images
│ │ ├── train-1.png
│ │ └── train-2.png
│ └── masks
│ ├── train-1.png
│ └── train-2.png
└── val
├── images
│ ├── val-1.png
│ └── val-2.png
└── masks
├── val-1.png
└── val-2.png
Colorectal Adenocarcinoma Gland (CRAG) dataset
Download the dataset from this link. Then organize this dataset like GlaS mentioned above.
Generating point labels
$ python scripts/generate_points.py /path/to/dataset -p 1e-4
The
-por--label-percentargument is for controlling the percentage of labeled pixels. Larger value means stronger supervision.
Then labels directory storing point labels will be generated alongside images and masks. Each csv file within labels directory correspond to a training image, with each row (a triple) representing a point:
p1_top,p1_left,p1_class
p2_top,p2_left,p2_class
Visualizing point labels
$ python scripts/visualize_points.py data_glas/train
You will see visualization outputs in data_glas/train/viz.
Training
Training from scratch
$ python train.py /path/to/dataset --epochs 100
Resume training from a checkpoint
$ python train.py /path/to/dataset --epochs 100 --checkpoint /path/to/checkpoint
Recording multple runs
By default, each run will be stored within a timestamped directory within records. The structure of a record directory is as follows:
records/20190423-1122-AM
├── checkpoints
│ ├── ckpt.0001.pth
│ ├── ckpt.0002.pth
│ └── ckpt.0003.pth
├── curves
│ ├── loss.png
│ ├── pixel_acc.png
│ └── sp_acc.png
├── history.csv
├── params
│ ├── 0.json
│ └── 1.json
└── source
checkpointsdirectory stores all training checkpointscurvesstores learning curves for loss and all metricsparamsstores CLI and configuration parameterssourcestores a snapshot of all source code filehistory.csvrecords the training history
Inference
We offer four types of inference utilities:
- Superpixel-wise inference (the
infer.pyscript) - Superpixel-wise inference with tiling strategy (the
infer_tile.pyscript) - Pixel-wise inference (the
pixel_infer.pyscript) - Pixel-wise inference with tiling strategy (the
pixel_infer_tile.pyscript)
Example:
$ python infer.py /path/to/test/data --checkpoint /path/to/checkpoint
$ python pixel_infer_tile.py /path/to/test/data --checkpoint /path/to/checkpoint --patch-size 400
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
