SkillAgentSearch skills...

WESUP

Source code for *Weakly Supervised Histopathology Image Segmentation with Sparse Point Annotations*.

Install / Use

/learn @mrcfps/WESUP
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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 -p or --label-percent argument 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
  • checkpoints directory stores all training checkpoints
  • curves stores learning curves for loss and all metrics
  • params stores CLI and configuration parameters
  • source stores a snapshot of all source code file
  • history.csv records the training history

Inference

We offer four types of inference utilities:

  • Superpixel-wise inference (the infer.py script)
  • Superpixel-wise inference with tiling strategy (the infer_tile.py script)
  • Pixel-wise inference (the pixel_infer.py script)
  • Pixel-wise inference with tiling strategy (the pixel_infer_tile.py script)

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

View on GitHub
GitHub Stars15
CategoryDevelopment
Updated1y ago
Forks3

Languages

Python

Security Score

75/100

Audited on Oct 2, 2024

No findings