Kelp-PS8B: Kelp Segmentation Model for PlanetScope 8-Band Imagery

Model Type: ONNX Semantic Segmentation
Application: Kelp forest detection in high-resolution satellite imagery
Input: 8-band PlanetScope imagery
Output: Binary segmentation mask (kelp vs. non-kelp)

Model Description

The Kelp-PS8B model is a deep learning semantic segmentation model specifically trained for detecting kelp forests in 8-band PlanetScope satellite imagery. This model processes all 8 spectral bands to provide accurate kelp segmentation for marine habitat monitoring and research.

Key Features:

  • Optimized for 8-band PlanetScope imagery
  • Standard normalization with pre-computed statistics
  • Efficient ONNX format for cross-platform deployment
  • Designed for large-scale geospatial processing

Model Details

  • Version: 20250626
  • Input Channels: 8
  • Input Size: 224x224 pixel tiles
  • Normalization: Standard (z-score) normalization
  • Output: Binary segmentation (0: background, 1: kelp)
  • Format: ONNX

Normalization Parameters

The model expects input images to be normalized using these statistics:

{
  "mean": [1720.0, 1715.0, 1913.0, 2088.0, 2274.0, 2290.0, 2613.0, 3970.0],
  "std": [747.0, 698.0, 739.0, 768.0, 849.0, 868.0, 849.0, 914.0],
}

Usage

1. Using kelp-o-matic CLI (recommended)

For command-line usage:

# Install kelp-o-matic
pip install git+https://github.com/HakaiInstitute/kelp-o-matic@dev

# List available models
kom list-models

# Run segmentation
kom segment \
    --model kelp-ps8b \
    --input /path/to/8band_planetscope_image.tif \
    --output /path/to/kelp_segmentation.tif \
    --batch-size 4 \
    --blur-kernel 5 \
    --morph-kernel 3

# Use specific model version
kom segment \
    --model kelp-ps8b \
    --version 20250626 \
    --input image.tif \
    --output result.tif

# For large images, adjust batch size based on available memory
kom segment \
    --model kelp-ps8b \
    --input large_image.tif \
    --output result.tif \
    --batch-size 8

2. Using kelp-o-matic Python API

The easiest way to use this model is through the kelp-o-matic package:

from kelp_o_matic import model_registry

# Load the model (automatically downloads if needed)
model = model_registry["kelp-ps8b"]

# Process a large geospatial image with automatic tiling
model.process(
    input_path="path/to/your/8band_image.tif",
    output_path="path/to/output/segmentation.tif",
    batch_size=4,
    crop_size=224,
    blur_kernel_size=5,  # Post-processing median blur
    morph_kernel_size=0,  # Morphological operations
)

# For more control, use the predict method directly
import rasterio
import numpy as np

with rasterio.open("your_image.tif") as src:
    # Read a 224x224 tile (8 bands)
    tile = src.read(window=((0, 224), (0, 224)))  # Shape: (8, 224, 224)
    tile = np.transpose(tile, (1, 2, 0))  # Convert to HWC
    
    # Add batch dimension and predict
    batch = np.expand_dims(tile, axis=0)  # Shape: (1, 224, 224, 8)
    batch = np.transpose(batch, (0, 3, 1, 2))  # Convert to BCHW
    
    # Run inference (preprocessing handled automatically)
    predictions = model.predict(batch)
    
    # Post-process to get final segmentation
    segmentation = model.postprocess(predictions)

3. Direct ONNX Runtime Usage

import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download

# Download the model
model_path = hf_hub_download(repo_id="HakaiInstitute/kelp-ps8b", filename="model.onnx")

# Load the model
session = ort.InferenceSession(model_path)

# Model normalization parameters
mean = np.array([1720.0, 1715.0, 1913.0, 2088.0, 2274.0, 2290.0, 2613.0, 3970.0])
std = np.array([747.0, 698.0, 739.0, 768.0, 849.0, 868.0, 849.0, 914.0])

# Preprocess your 8-band image
def preprocess(image):
    """
    Preprocess 8-band image for model input
    image: numpy array of shape [height, width, 8] with pixel values 0-65535
    """   
    # Apply z-score normalization
    image = (image - mean) / std
    
    # Reshape to model input format [batch, channels, height, width]
    image = np.transpose(image, (2, 0, 1))  # HWC to CHW
    image = np.expand_dims(image, axis=0)  # Add batch dimension
    
    return image

# Run inference
preprocessed = preprocess(your_8band_image)
input_name = session.get_inputs()[0].name
output = session.run(None, {input_name: preprocessed})

# Postprocess to get binary mask
logits = output[0]
prediction = np.argmax(logits, axis=1).squeeze(0).astype(np.uint8)

4. Using HuggingFace Hub Integration

from huggingface_hub import hf_hub_download
import onnxruntime as ort

# Download and load model
model_path = hf_hub_download(
    repo_id="HakaiInstitute/kelp-ps8b",
    filename="model.onnx",
    cache_dir="./models"
)

session = ort.InferenceSession(model_path)
# ... continue with preprocessing and inference as above

Installation

For kelp-o-matic usage:

# Via pip
pip install git+https://github.com/HakaiInstitute/kelp-o-matic@dev

For direct ONNX usage:

pip install onnxruntime huggingface-hub numpy
# For GPU support:
pip install onnxruntime-gpu

Input Requirements

  • Image Format: 8-band raster (GeoTIFF recommended)
  • Band Order: Blue, Green, Red, Near-IR, and 4 additional PlanetScope bands
  • Pixel Values: Original PlanetScope digital numbers (0-65535 range)
  • Spatial Resolution: Optimized for ~3m PlanetScope resolution

Output Format

  • Type: Single-band raster
  • Values:
    • 0: Non-kelp (background, water, other features)
    • 1: Kelp forest
  • Format: Matches input raster format and projection
  • Spatial Resolution: Same as input

Performance Notes

  • Required Tile Size: 224x224 pixels
  • Batch Size: Start with 4, adjust based on available GPU memory

Large Image Processing

For processing large geospatial images, the kelp-o-matic package handles:

  • Automatic Tiling: Splits large images into manageable tiles
  • Overlap Handling: Uses overlapping tiles to avoid edge artifacts
  • Memory Management: Processes tiles in batches to manage memory usage
  • Geospatial Metadata: Preserves coordinate reference system and geotransforms
  • Post-processing: Optional median filtering and morphological operations

Citation

If you use this model in your research, please cite:

@software{Denouden_Kelp-O-Matic,
  author = {Denouden, Taylor and Reshitnyk, Luba},
  doi = {10.5281/zenodo.7672166},
  title = {{Kelp-O-Matic}},
  url = {https://github.com/HakaiInstitute/kelp-o-matic}
}

License

This model is built on top of the made-with-clay/Clay foundation model. Please see the respective licenses:

Related Resources

Contact

For questions or issues:

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for HakaiInstitute/kelp-ps8b

Quantized
(1)
this model