Skip to main content

Overview

DigiPathAI provides specialized models for colon cancer segmentation, trained on the DigestPath dataset. These models detect and segment cancerous regions in colorectal histopathology slides.

DigestPath Dataset

The DigestPath dataset contains annotated whole slide images of colorectal cancer tissue. The model ensemble includes:

Inception

Multi-scale feature extraction for diverse tissue patterns

DenseNet

Dense connections for efficient feature learning

DeepLabV3

Precise boundary segmentation with atrous convolution

Model Details

The colon cancer models are automatically managed by DigiPathAI:
# From Segmentation.py lines 232-246
if mode == 'colon':
    path = os.path.join(home, '.DigiPathAI/digestpath_models')
    if (not os.path.exists(os.path.join(path, 'digestpath_inception.h5'))) or \
        (not os.path.exists(os.path.join(path, 'digestpath_deeplabv3.h5'))) or \
        (not os.path.exists(os.path.join(path, 'digestpath_densenet.h5'))):
        if status is not None: status['status'] = "Downloading Trained Models"
        download_digestpath() 
        model_path_inception = os.path.join(path, 'digestpath_inception.h5')
        model_path_deeplabv3 = os.path.join(path, 'digestpath_deeplabv3.h5')
        model_path_densenet = os.path.join(path, 'digestpath_densenet.h5')
    else :
        if status is not None: status['status'] = "Found Trained Models, Skipping download"
        model_path_inception = os.path.join(path, 'digestpath_inception.h5')
        model_path_deeplabv3 = os.path.join(path, 'digestpath_deeplabv3.h5')
        model_path_densenet = os.path.join(path, 'digestpath_densenet.h5')
Models are stored in ~/.DigiPathAI/digestpath_models/ and include:
  • digestpath_inception.h5
  • digestpath_deeplabv3.h5
  • digestpath_densenet.h5

Usage Example

Basic Colon Segmentation

from DigiPathAI.Segmentation import getSegmentation

# Segment colon cancer tissue
prediction = getSegmentation(
    img_path='colon_slide.tiff',
    mode='colon',
    patch_size=256,
    stride_size=128,
    batch_size=32,
    quick=False  # Use ensemble of all three models
)

Quick Mode (Single Model)

# Use only DenseNet for faster inference
prediction = getSegmentation(
    img_path='colon_slide.tiff',
    mode='colon',
    model='dense',
    quick=True
)

With Test-Time Augmentation

# Improve accuracy with TTA
prediction = getSegmentation(
    img_path='colon_slide.tiff',
    mode='colon',
    tta_list=['FLIP_LEFT_RIGHT', 'ROTATE_90'],
    quick=False
)
For production use with colon tissue, set quick=False to leverage the full ensemble. This provides better accuracy and uncertainty estimates.

Parameters

ParameterDescriptionDefaultColon-Specific Notes
modeTissue type-Must be set to 'colon'
modelArchitecture choice'dense'Options: ‘dense’, ‘inception’, ‘deeplabv3’
quickSingle vs ensembleTrueSet to False for ensemble
patch_sizeInference patch size256Recommended: 256 for colon
stride_sizeSliding window stride128Smaller values = more overlap
batch_sizeBatch size for inference32Adjust based on GPU memory

Output

The segmentation returns three files:
  1. Probability Map - Continuous probability values (0-1)
  2. Binary Mask - Thresholded segmentation (threshold=0.3)
  3. Uncertainty Map - Model variance for quality assessment
# Outputs are saved as pyramidal TIFF files
# - probs_path: Probability heatmap
# - mask_path: Binary segmentation mask  
# - uncertainty_path: Prediction uncertainty

Build docs developers (and LLMs) love