返回模型
说明文档
Kelp-PS8B:用于PlanetScope 8波段影像的海带分割模型
模型类型: ONNX 语义分割
应用场景: 高分辨率卫星影像中的海带森林检测
输入: 8波段 PlanetScope 影像
输出: 二值分割掩膜(海带 vs 非海带)
模型描述
Kelp-PS8B 模型是一个深度学习语义分割模型,专门用于在8波段 PlanetScope 卫星影像中检测海带森林。该模型处理全部8个光谱波段,为海洋栖息地监测和研究提供准确的海带分割。
主要特性:
- 针对8波段 PlanetScope 影像优化
- 使用预计算统计数据进行标准化归一化
- 高效的 ONNX 格式,支持跨平台部署
- 专为大规模地理空间处理设计
模型详情
- 版本: 20250626
- 输入通道: 8
- 输入尺寸: 224x224 像素瓦片
- 归一化: 标准(z-score)归一化
- 输出: 二值分割(0:背景,1:海带)
- 格式: ONNX
归一化参数
模型期望使用以下统计数据对输入图像进行归一化:
{
\"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],
}
使用方法
1. 使用 kelp-o-matic CLI(推荐)
命令行使用方式:
# 安装 kelp-o-matic
pip install git+https://github.com/HakaiInstitute/kelp-o-matic@dev
# 列出可用模型
kom list-models
# 运行分割
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
# 使用特定模型版本
kom segment \
--model kelp-ps8b \
--version 20250626 \
--input image.tif \
--output result.tif
# 对于大图像,根据可用内存调整批次大小
kom segment \
--model kelp-ps8b \
--input large_image.tif \
--output result.tif \
--batch-size 8
2. 使用 kelp-o-matic Python API
使用此模型最简单的方式是通过 kelp-o-matic 包:
from kelp_o_matic import model_registry
# 加载模型(如需要会自动下载)
model = model_registry[\"kelp-ps8b\"]
# 处理大型地理空间图像,自动分块
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, # 后处理中值模糊
morph_kernel_size=0, # 形态学操作
)
# 如需更多控制,可直接使用 predict 方法
import rasterio
import numpy as np
with rasterio.open(\"your_image.tif\") as src:
# 读取一个 224x224 瓦片(8个波段)
tile = src.read(window=((0, 224), (0, 224))) # 形状:(8, 224, 224)
tile = np.transpose(tile, (1, 2, 0)) # 转换为 HWC 格式
# 添加批次维度并进行预测
batch = np.expand_dims(tile, axis=0) # 形状:(1, 224, 224, 8)
batch = np.transpose(batch, (0, 3, 1, 2)) # 转换为 BCHW 格式
# 运行推理(自动处理预处理)
predictions = model.predict(batch)
# 后处理以获取最终分割结果
segmentation = model.postprocess(predictions)
3. 直接使用 ONNX Runtime
import numpy as np
import onnxruntime as ort
from huggingface_hub import hf_hub_download
# 下载模型
model_path = hf_hub_download(repo_id=\"HakaiInstitute/kelp-ps8b\", filename=\"model.onnx\")
# 加载模型
session = ort.InferenceSession(model_path)
# 模型归一化参数
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])
# 预处理您的8波段图像
def preprocess(image):
\"\"\"
预处理8波段图像用于模型输入
image: 形状为 [height, width, 8] 的 numpy 数组,像素值范围 0-65535
\"\"\"
# 应用 z-score 归一化
image = (image - mean) / std
# 重塑为模型输入格式 [batch, channels, height, width]
image = np.transpose(image, (2, 0, 1)) # HWC 转为 CHW
image = np.expand_dims(image, axis=0) # 添加批次维度
return image
# 运行推理
preprocessed = preprocess(your_8band_image)
input_name = session.get_inputs()[0].name
output = session.run(None, {input_name: preprocessed})
# 后处理获取二值掩膜
logits = output[0]
prediction = np.argmax(logits, axis=1).squeeze(0).astype(np.uint8)
4. 使用 HuggingFace Hub 集成
from huggingface_hub import hf_hub_download
import onnxruntime as ort
# 下载并加载模型
model_path = hf_hub_download(
repo_id=\"HakaiInstitute/kelp-ps8b\",
filename=\"model.onnx\",
cache_dir=\"./models\"
)
session = ort.InferenceSession(model_path)
# ... 继续进行预处理和推理,如上所示
安装
用于 kelp-o-matic 使用:
# 通过 pip 安装
pip install git+https://github.com/HakaiInstitute/kelp-o-matic@dev
用于直接 ONNX 使用:
pip install onnxruntime huggingface-hub numpy
# 如需 GPU 支持:
pip install onnxruntime-gpu
输入要求
- 图像格式: 8波段栅格(推荐 GeoTIFF)
- 波段顺序: 蓝光、绿光、红光、近红外以及4个额外的 PlanetScope 波段
- 像素值: 原始 PlanetScope 数字值(0-65535 范围)
- 空间分辨率: 针对 ~3m PlanetScope 分辨率优化
输出格式
- 类型: 单波段栅格
- 值:
- 0:非海带(背景、水体、其他特征)
- 1:海带森林
- 格式: 与输入栅格格式和投影匹配
- 空间分辨率: 与输入相同
性能说明
- 所需瓦片大小: 224x224 像素
- 批次大小: 从4开始,根据可用 GPU 内存调整
大图像处理
对于处理大型地理空间图像,kelp-o-matic 包会处理以下事项:
- 自动分块: 将大图像分割成可管理的瓦片
- 重叠处理: 使用重叠瓦片避免边缘伪影
- 内存管理: 分批处理瓦片以管理内存使用
- 地理空间元数据: 保留坐标参考系统和地理变换
- 后处理: 可选的中值滤波和形态学操作
引用
如果您在研究中使用此模型,请引用:
@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}
}
许可证
此模型基于 made-with-clay/Clay 基础模型构建。请参阅各自的许可证:
- Kelp-O-Matic 包:MIT 许可证 - 详情请参阅 kelp-o-matic 仓库
- Clay 基础模型:Apache 2.0 许可证 - 详情请参阅 LICENSE.Clay
相关资源
- 文档: kelp-o-matic.readthedocs.io
- 源代码: github.com/HakaiInstitute/kelp-o-matic
- 其他模型: 查看 Hakai Institute HuggingFace 组织 获取更多海带分割模型
联系方式
如有问题或反馈:
- 在 GitHub 仓库 提交 issue
- 联系:Hakai Institute
HakaiInstitute/kelp-ps8b
作者 HakaiInstitute
image-segmentation
↓ 0
♥ 0
创建时间: 2025-07-28 21:18:32+00:00
更新时间: 2025-08-18 20:18:50+00:00
在 Hugging Face 上查看文件 (3)
.gitattributes
README.md
model.onnx
ONNX