360 Secure SkillHub
360 安全技能中心

geoskill-ai-training-data-annotation

基于小型 U-Net(torch+CUDA)对单波段遥感影像做目标/背景二值语义分割生成预标注,用概率图香农熵做主动学习不确定性 Top-k 选样,输出 COCO JSON、GeoJSON 与不确定性 GeoTIFF,并提供无需 GPU 的 Otsu 阈值基线和离线合成数据模式。

ruiduobao
ruiduobao
热度 7.65
最近更新 2026-08-04 19:23:32
分类:数据依赖:代码执行 / 读写文件应用场景:数据处理 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add geoskill-ai-training-data-annotation
Metadata
name
geoskill-ai-training-data-annotation
description
小型 U-Net 二值语义分割 (torch+CUDA) 预标注 + 主动学习不确定性选样,输出 COCO/GeoJSON 标注与不确定性栅格

AI训练数据标注 | AI Training Data Annotation

Automatically generates pre-annotations (pseudo-labels) for remote sensing imagery and uses active learning to select the most uncertain samples for manual review, outputting both standard COCO JSON and GeoJSON annotation formats plus an uncertainty raster.

Core model: a small U-Net (unet-lite, base=8, 3-level encoder-decoder with skip connections) performing target vs background binary semantic segmentation by default on torch + CUDA. The model infers on single-band imagery to produce an (H, W, 2) softmax probability map; the target probability is Otsu-thresholded and connected components are extracted with 8-neighborhood connectivity to generate bbox pre-annotations. Uncertainty is computed as the Shannon entropy of the probability map; the Top-k samples by regional mean entropy are selected for manual review. Pretrained weights anno_unet_weights.pt are shipped with the skill (automatically trained on GPU and persisted at first run when missing). The --method otsu classical threshold baseline is also retained for comparison and GPU-free environments.

Dependencies / 依赖

pip install numpy rasterio scipy torch --index-url https://download.pytorch.org/whl/cu121

The classical baseline (--method otsu) does not require torch.

Usage / 使用方法

Example 1 (Synthetic Data, Offline)

python geoskill-ai-training-data-annotation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

Example 2: Automatic Annotation of Synthetic Data (Offline)

python geoskill-ai-training-data-annotation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-review 2 --output-dir ./out

Example 3: Real-Image Pre-Annotation

python geoskill-ai-training-data-annotation.py --input scene.tif --threshold 60 --min-area 9 --format both --output-dir ./out

示例 4:仅导出 COCO

python geoskill-ai-training-data-annotation.py --bbox 121.0 31.0 122.0 32.0 --synthetic --format coco --output-dir ./out

Output / 输出

File Format Description
annotations_coco.json JSON Standard COCO annotations (images/annotations/categories)
annotations.geojson GeoJSON Georeferenced pre-annotation boxes + confidence/uncertainty/review flags
uncertainty.tif GeoTIFF Per-pixel entropy (uncertainty) raster
output-manifest.json JSON Run manifest (inputs/outputs/QA/exit code)

Data Source / 数据源 / Source

Local GeoTIFF, or --synthetic (probability map with high entropy at boundaries; target ground truth known).

Privacy / 隐私声明 / Privacy

  • Runs offline by default; --synthetic mode requires no network at all.
  • All processing is done locally; no user data is ever uploaded.

License / License

MIT



name: geoskill-ai-training-data-annotation description: '小型 U-Net 二值语义分割 (torch+CUDA) 预标注 + 主动学习不确定性选样,输出 COCO/GeoJSON 标注与不确定性栅格'

AI训练数据标注 | AI Training Data Annotation

为遥感影像自动生成预标注(伪标签),并用主动学习挑出最不确定的样本送人工复核,输出标准 COCO JSON 与 GeoJSON 两种标注格式及不确定性栅格。

核心模型:小型 U-Net (unet-lite,base=8,3 级编解码 + skip),默认在 torch + CUDA 上做 target vs background 二值语义分割。模型对单波段影像推理得到 (H, W, 2) softmax 概率图,对 target 概率做 Otsu 阈值化 + 8 邻域连通域,生成 bbox 预标注;不确定性 = 概率图香农熵,按区域平均熵 Top-k 选样送人工复核。随附预训练权重 anno_unet_weights.pt(缺失时在首次运行时 GPU 自动训练并落盘)。同时保留 --method otsu 经典阈值基线用于对比与无 GPU 环境。

依赖

pip install numpy rasterio scipy torch --index-url https://download.pytorch.org/whl/cu121

如要跑经典基线(--method otsu)无需 torch。

使用方法

示例 1(合成数据,离线)

python geoskill-ai-training-data-annotation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

示例 2:合成数据自动标注(离线)

python geoskill-ai-training-data-annotation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --n-review 2 --output-dir ./out

示例 3:真实影像预标注

python geoskill-ai-training-data-annotation.py --input scene.tif --threshold 60 --min-area 9 --format both --output-dir ./out

示例 4:仅导出 COCO

python geoskill-ai-training-data-annotation.py --bbox 121.0 31.0 122.0 32.0 --synthetic --format coco --output-dir ./out

输出

文件 格式 说明
annotations_coco.json JSON 标准 COCO 标注(images/annotations/categories)
annotations.geojson GeoJSON 地理坐标预标注框 + 置信度/不确定性/复核标记
uncertainty.tif GeoTIFF 逐像元熵(不确定性)栅格
output-manifest.json JSON 运行清单(输入/输出/QA/退出码)

数据源 / Source

本地 GeoTIFF,或 --synthetic(影像 + 边界高熵的概率图,目标真值已知)。

隐私声明 / Privacy

  • 默认离线运行,--synthetic 模式完全无网络。
  • 所有处理在本地完成,不上传任何用户数据。

License

MIT