ExpertSegmentation is a decision tree-based semantic segmentation tool for microstructural images with domain knowledge-informed physical targets for the resulting segmentation.
Supported targets include volume fractions and minimum or maximum phase connectivity.
- MIT License
- Docs: https://expertsegmentation.readthedocs.io/en/latest/index.html
Recommended to use Anaconda distribution for Python environments and package management.
After cloning the expertsegmentation repo navigate to the top level:
$ conda env create -f environment.yml
$ conda activate expert-seg
$ pip install .
Hand-label image with third-party tool (Ilastik, the SAMBA web-based tool) and save both the raw input image and the labeled image.
import expertsegmentation as seg
import tifffile
img = tifffile.imread("path to filename")
labels = tifffile.imread("<path to filename>")
dataset = seg.SegDataset(img, labels)
The tuning hyperparameter lambda represents the weight of the target property on the segmentation. Increasing lambda drives the segmentation to weight the target more highly, but if too large may result in a failed segmentation.
When segmenting with multiple targets, lambda can also be used to tune the relative desired weight of each target.
If a lambda is not specified, the default is lambda=1.
# No target property
model = seg.SegmentModel()
# Volume fraction target (51% on the class labeled 1, 49% on class 2)
model = seg.SegmentModel(objective='volume_fraction',
target={
1: 0.51,
2: 0.49,
},
lambd=1,
n_epochs=100)
model.segment(dataset)
model.plot_results(dataset)
model.plot_steps(dataset)
model.print_metrics()