Install
openclaw skills install @ruiduobao/geoskill-few-shot-classificationopenclaw skills install @ruiduobao/geoskill-few-shot-classificationClassifies an entire image using very few labeled samples (1–5 per class): the feature mean of each class's support samples serves as the "prototype", each pixel is assigned to the nearest prototype, and a softmax(−distance) confidence is provided; few-shot episode accuracy evaluation is supported.
This skill is an offline numpy-equivalent implementation of Prototypical Networks few-shot learning: without depending on torch, it reproduces the metric-learning paradigm through "feature extraction → support-set standardization → prototype computation → nearest-prototype classification by Euclidean distance"; unit tests cover 1-shot and multi-shot episode accuracy, probability normalization, and errors for insufficient samples.
pip install numpy rasterio scipy scikit-learn geopandas shapely
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-shot 3 --output-dir ./out
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-shot 1 --output-dir ./out
python geoskill-few-shot-classification.py --input scene.tif --n-classes 4 --n-shot 5 --output-dir ./out
| File | Format | Description |
|---|---|---|
classification.tif | GeoTIFF | Full-image nearest-prototype classification label map |
few_shot_report.json | JSON | Episode accuracy/confidence/number of support samples |
output-manifest.json | JSON | Run manifest (inputs/outputs/QA/exit code) |
Local multi-band GeoTIFF, or --synthetic for a three-class spectrally separable scenario (ground truth used for episode evaluation).
--synthetic mode requires no network at all.MIT
用极少量标注样本(每类 1~5 个)完成整幅影像分类:每类支持样本的特征均值作为"原型",像元按最近原型归类,并给出 softmax(-距离) 置信度;支持少样本回合 (episode) 精度评估。
本 skill 是 Prototypical Networks 少样本学习的离线 numpy 等价实现:不依赖 torch,用"特征提取 -> 支持集标准化 -> 原型计算 -> 欧氏距离最近原型分类"复现度量学习范式;1-shot 与多 shot 回合精度、概率归一性、样本不足报错等均有单元测试覆盖。
pip install numpy rasterio scipy scikit-learn geopandas shapely
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-shot 3 --output-dir ./out
python geoskill-few-shot-classification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-shot 1 --output-dir ./out
python geoskill-few-shot-classification.py --input scene.tif --n-classes 4 --n-shot 5 --output-dir ./out
| 文件 | 格式 | 说明 |
|---|---|---|
classification.tif | GeoTIFF | 整幅最近原型分类标签图 |
few_shot_report.json | JSON | episode 精度/置信度/支持样本数 |
output-manifest.json | JSON | 运行清单(输入/输出/QA/退出码) |
本地多波段 GeoTIFF,或 --synthetic 三类光谱可分场景(真值用于 episode 评估)。
--synthetic 模式完全无网络。MIT