Upload source code snapshot
Browse files
README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Typical Marine Ecological Environment Feature Recognition
|
| 2 |
+
|
| 3 |
+
典型海洋生态环境地物要素识别项目。项目目标不是单一浒苔二分类,而是把多种海洋生态环境要素统一到一个可训练、可推理、可扩展的遥感识别框架中。
|
| 4 |
+
|
| 5 |
+
当前参考/整合方向来自 `BiJiaNet` 中的几个任务:
|
| 6 |
+
|
| 7 |
+
- `EntGreenTide`: 浒苔/绿潮。
|
| 8 |
+
- `RedTide`: 赤潮。
|
| 9 |
+
- `SargGoldenTide`: 马尾藻/金潮。
|
| 10 |
+
- `AquacultureArea`: 养殖区、养殖设施或相关海上人工目标。
|
| 11 |
+
|
| 12 |
+
## Core Constraint
|
| 13 |
+
|
| 14 |
+
不假设有海岸线、陆地掩膜、外部矢量层或其他 GIS 先验可用。
|
| 15 |
+
|
| 16 |
+
陆地、黑区、无效影像区、云雾、水体背景等必须通过数据标签、hard negative 样本、影像有效性规则和模型上下文学习来处理,不能依赖外部矢量后处理。
|
| 17 |
+
|
| 18 |
+
## Target Classes
|
| 19 |
+
|
| 20 |
+
推荐统一语义类别:
|
| 21 |
+
|
| 22 |
+
| ID | Class |
|
| 23 |
+
| --- | --- |
|
| 24 |
+
| 0 | other/background |
|
| 25 |
+
| 1 | invalid/no-data/black area |
|
| 26 |
+
| 2 | water |
|
| 27 |
+
| 3 | land/non-water hard negative |
|
| 28 |
+
| 4 | cloud/haze/shadow |
|
| 29 |
+
| 5 | green_tide |
|
| 30 |
+
| 6 | red_tide |
|
| 31 |
+
| 7 | golden_tide |
|
| 32 |
+
| 8 | aquaculture |
|
| 33 |
+
|
| 34 |
+
旧二分类标签不会被直接解释成“所有其他类别都为负样本”。导入时需要保留其来源、要素类型和标签语义。
|
| 35 |
+
|
| 36 |
+
## Data Strategy
|
| 37 |
+
|
| 38 |
+
数据集采用 manifest 驱动,允许并保留:
|
| 39 |
+
|
| 40 |
+
- 128、256、512 等不同 tile 尺度。
|
| 41 |
+
- GF1、GF2、GF6 等不同卫星。
|
| 42 |
+
- PMS、MUX、MSS、PAN 等不同传感器。
|
| 43 |
+
- 2 米、8 米等不同空间分辨率。
|
| 44 |
+
- 已融合影像和 PAN+MSS 原始组合。
|
| 45 |
+
- 全景影像、切片影像、二值 mask、多类别 mask、推理结果。
|
| 46 |
+
|
| 47 |
+
详细规范见 [docs/dataset_standard.md](docs/dataset_standard.md)。
|
| 48 |
+
|
| 49 |
+
## Key Scripts
|
| 50 |
+
|
| 51 |
+
- `scripts/build_marine_feature_dataset.py`: 扫描服务器或本地数据根目录,生成规范化 `assets_raw.jsonl`、`samples.jsonl` 和 `asset_inventory.csv`。
|
| 52 |
+
- `scripts/infer_whole_scene.py`: 整景滑窗推理,支持重叠加权、条带写出、可选 PAN+MSS 边融合边推理。
|
| 53 |
+
- `scripts/postprocess_mask.py`: 临时后处理脚本,只作为黑区/明显非目标区域清理工具,不能替代最终多类别模型。
|
| 54 |
+
- `train_seaweed_segmentation.py`: 当前遗留 DINOv3 + DeepLabV3+ 训练入口,后续会重构为多要素多头训练入口。
|
| 55 |
+
- `dinov3_deeplabv3plus.py`: 当前 DINOv3 编码器 + DeepLabV3+ 解码器实现。
|
| 56 |
+
|
| 57 |
+
## Normalized Dataset Example
|
| 58 |
+
|
| 59 |
+
```powershell
|
| 60 |
+
python scripts/build_marine_feature_dataset.py `
|
| 61 |
+
--roots D:\hutai-2 D:\Dataset E:\Dataset `
|
| 62 |
+
--output-root D:\marine_feature_dataset
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
输出:
|
| 66 |
+
|
| 67 |
+
```text
|
| 68 |
+
D:\marine_feature_dataset\
|
| 69 |
+
manifests\
|
| 70 |
+
assets_raw.jsonl
|
| 71 |
+
samples.jsonl
|
| 72 |
+
reports\
|
| 73 |
+
asset_inventory.csv
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Near-Term Refactor Plan
|
| 77 |
+
|
| 78 |
+
1. 盘点服务器上所有可用要素数据,生成数据资产清单。
|
| 79 |
+
2. 统一 manifest 格式,保留尺度、卫星、传感器、分辨率、融合状态等元数据。
|
| 80 |
+
3. 将当前浒苔二分类模型升级为多类别/多头模型:
|
| 81 |
+
- valid/invalid head
|
| 82 |
+
- scene context head: water, land, cloud/shadow, other
|
| 83 |
+
- ecological feature head: green tide, red tide, golden tide, aquaculture
|
| 84 |
+
4. 改造训练 sampler,使不同尺度、不同传感器数据能按元数据混合训练。
|
| 85 |
+
5. 改造整景推理输出,多通道概率图和最终要素 mask 分开保存。
|
| 86 |
+
|
| 87 |
+
## Notes
|
| 88 |
+
|
| 89 |
+
- `data/`、`outputs/`、大影像和模型 checkpoint 不进入 git。
|
| 90 |
+
- GF2 这类 PAN+MSS 数据应在推理时边融合边推理,避免落盘整幅融合图。
|
| 91 |
+
- GF6 这类已融合图可以直接整景滑窗推理。
|
| 92 |
+
- 当前 GF6 浒苔结果只能作为候选区,不能作为最终产品,因为旧模型没有显式学习陆地、黑区和其他生态要素类别。
|
configs/marine_feature_multitask.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"project_name": "Typical Marine Ecological Environment Feature Recognition",
|
| 3 |
+
"task": "marine_feature_multitask_segmentation",
|
| 4 |
+
"num_classes": 9,
|
| 5 |
+
"classes": [
|
| 6 |
+
"other",
|
| 7 |
+
"invalid",
|
| 8 |
+
"water",
|
| 9 |
+
"land",
|
| 10 |
+
"cloud_shadow",
|
| 11 |
+
"green_tide",
|
| 12 |
+
"red_tide",
|
| 13 |
+
"golden_tide",
|
| 14 |
+
"aquaculture"
|
| 15 |
+
],
|
| 16 |
+
"input": {
|
| 17 |
+
"supported_patch_sizes": [128, 256, 512, 1024],
|
| 18 |
+
"default_train_size": 256,
|
| 19 |
+
"supported_satellites": ["GF1", "GF2", "GF6", "HY", "Sentinel2", "Landsat"],
|
| 20 |
+
"supported_sensors": ["PMS", "MUX", "MSS", "PAN", "WFV"],
|
| 21 |
+
"default_bands": ["blue", "green", "red", "nir"],
|
| 22 |
+
"allow_pan_mss_streaming_fusion": true,
|
| 23 |
+
"allow_fused_products": true
|
| 24 |
+
},
|
| 25 |
+
"model": {
|
| 26 |
+
"encoder": "dinov3_vitl16",
|
| 27 |
+
"decoder": "deeplabv3plus",
|
| 28 |
+
"heads": {
|
| 29 |
+
"semantic": 9,
|
| 30 |
+
"validity": 2,
|
| 31 |
+
"context": 5,
|
| 32 |
+
"ecological_element": 4
|
| 33 |
+
}
|
| 34 |
+
},
|
| 35 |
+
"loss": {
|
| 36 |
+
"semantic_weight": 1.0,
|
| 37 |
+
"validity_weight": 0.3,
|
| 38 |
+
"context_weight": 0.5,
|
| 39 |
+
"element_weight": 1.0,
|
| 40 |
+
"ignore_index": 255
|
| 41 |
+
},
|
| 42 |
+
"dataset": {
|
| 43 |
+
"manifest": "data_marine_features/manifests/samples.jsonl",
|
| 44 |
+
"do_not_assume_external_land_or_coastline_mask": true,
|
| 45 |
+
"preserve_native_resolution_metadata": true,
|
| 46 |
+
"preserve_native_patch_size_metadata": true
|
| 47 |
+
}
|
| 48 |
+
}
|
docs/dataset_standard.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Typical Marine Ecological Environment Feature Dataset Standard
|
| 2 |
+
|
| 3 |
+
This project uses a manifest-driven dataset layout for marine ecological environment
|
| 4 |
+
feature recognition. It is designed to keep different patch sizes, satellites,
|
| 5 |
+
sensors, spatial resolutions, and fusion states instead of forcing everything into
|
| 6 |
+
one fixed tile format.
|
| 7 |
+
|
| 8 |
+
## Scope
|
| 9 |
+
|
| 10 |
+
Target feature families:
|
| 11 |
+
|
| 12 |
+
- `green_tide`: Enteromorpha / green tide / seaweed.
|
| 13 |
+
- `red_tide`: red tide / harmful algal bloom.
|
| 14 |
+
- `golden_tide`: Sargassum / golden tide.
|
| 15 |
+
- `aquaculture`: aquaculture area, rafts, cages, ponds, or related facilities.
|
| 16 |
+
- `water`: valid water background.
|
| 17 |
+
- `land`: land or non-water hard negative.
|
| 18 |
+
- `invalid`: black border, no-data, saturated, missing, or otherwise unusable pixels.
|
| 19 |
+
- `cloud_shadow`: cloud, haze, cloud shadow, or bright atmospheric interference.
|
| 20 |
+
- `other`: valid but not assigned to the categories above.
|
| 21 |
+
|
| 22 |
+
No external coastline, land-mask vector, or GIS mask is assumed to exist. Land,
|
| 23 |
+
invalid area, and water/background handling must be represented by dataset labels,
|
| 24 |
+
hard-negative samples, or image-derived validity rules.
|
| 25 |
+
|
| 26 |
+
## Canonical Directory Layout
|
| 27 |
+
|
| 28 |
+
```text
|
| 29 |
+
data_marine_features/
|
| 30 |
+
manifests/
|
| 31 |
+
assets_raw.jsonl
|
| 32 |
+
samples.jsonl
|
| 33 |
+
splits/
|
| 34 |
+
train.txt
|
| 35 |
+
val.txt
|
| 36 |
+
test.txt
|
| 37 |
+
images/
|
| 38 |
+
<asset_id>.<ext> # optional symlink or copied tile
|
| 39 |
+
masks/
|
| 40 |
+
<sample_id>.<ext> # optional symlink or copied mask
|
| 41 |
+
previews/
|
| 42 |
+
<sample_id>.png
|
| 43 |
+
reports/
|
| 44 |
+
asset_inventory.csv
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
The canonical source of truth is `manifests/samples.jsonl`. Files may remain in
|
| 48 |
+
their original locations; `images/` and `masks/` are optional conveniences.
|
| 49 |
+
|
| 50 |
+
## `samples.jsonl` Schema
|
| 51 |
+
|
| 52 |
+
Each line is one image sample or tile.
|
| 53 |
+
|
| 54 |
+
```json
|
| 55 |
+
{
|
| 56 |
+
"sample_id": "gf6_20250604_green_tide_000001",
|
| 57 |
+
"element": "green_tide",
|
| 58 |
+
"task_type": "semantic_segmentation",
|
| 59 |
+
"image_path": "D:/.../image.tif",
|
| 60 |
+
"mask_path": "D:/.../mask.tif",
|
| 61 |
+
"label_encoding": {"0": "background", "1": "green_tide"},
|
| 62 |
+
"satellite": "GF6",
|
| 63 |
+
"sensor": "PMS",
|
| 64 |
+
"resolution_m": 2.0,
|
| 65 |
+
"patch_size": 256,
|
| 66 |
+
"bands": ["blue", "green", "red", "nir"],
|
| 67 |
+
"band_count": 4,
|
| 68 |
+
"dtype": "uint16",
|
| 69 |
+
"is_fused": true,
|
| 70 |
+
"has_pan": false,
|
| 71 |
+
"pan_path": null,
|
| 72 |
+
"acquired_at": "2025-06-04",
|
| 73 |
+
"source_project": "EntGreenTide",
|
| 74 |
+
"source_dataset": "GF6_PMS_E121.1_N33.6_20250604_L1A1420584616",
|
| 75 |
+
"split": "train",
|
| 76 |
+
"quality_flags": ["valid_image"],
|
| 77 |
+
"notes": ""
|
| 78 |
+
}
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
Required fields:
|
| 82 |
+
|
| 83 |
+
- `sample_id`
|
| 84 |
+
- `element`
|
| 85 |
+
- `task_type`
|
| 86 |
+
- `image_path`
|
| 87 |
+
- `satellite`
|
| 88 |
+
- `sensor`
|
| 89 |
+
- `patch_size`
|
| 90 |
+
- `band_count`
|
| 91 |
+
- `is_fused`
|
| 92 |
+
- `source_project`
|
| 93 |
+
|
| 94 |
+
Recommended fields:
|
| 95 |
+
|
| 96 |
+
- `mask_path`
|
| 97 |
+
- `resolution_m`
|
| 98 |
+
- `bands`
|
| 99 |
+
- `dtype`
|
| 100 |
+
- `has_pan`
|
| 101 |
+
- `pan_path`
|
| 102 |
+
- `acquired_at`
|
| 103 |
+
- `split`
|
| 104 |
+
- `quality_flags`
|
| 105 |
+
|
| 106 |
+
## Multi-Scale Policy
|
| 107 |
+
|
| 108 |
+
Patch sizes such as 128, 256, 512, and full-scene windows are all valid. They are
|
| 109 |
+
not merged destructively. Training code should sample them with metadata-aware
|
| 110 |
+
transforms:
|
| 111 |
+
|
| 112 |
+
- Keep `patch_size` in the manifest.
|
| 113 |
+
- Resize only inside the training transform when the model requires it.
|
| 114 |
+
- Preserve the original spatial resolution in `resolution_m`.
|
| 115 |
+
- For full-scene inference, use sliding windows whose size is a runtime parameter.
|
| 116 |
+
|
| 117 |
+
## Multi-Sensor Policy
|
| 118 |
+
|
| 119 |
+
Different satellites and sensors are expected:
|
| 120 |
+
|
| 121 |
+
- GF1, GF2, GF6, and other optical satellites can coexist.
|
| 122 |
+
- Fused PMS/MUX products and raw PAN+MSS products can coexist.
|
| 123 |
+
- If PAN+MSS are available, keep both paths and mark `has_pan=true`.
|
| 124 |
+
- If already fused, mark `is_fused=true`.
|
| 125 |
+
- Do not assume band order from the filename alone; record `bands` when known.
|
| 126 |
+
|
| 127 |
+
## Label Policy
|
| 128 |
+
|
| 129 |
+
The final model should not be binary seaweed/background. It should learn ecological
|
| 130 |
+
elements and scene context. A recommended unified semantic target is:
|
| 131 |
+
|
| 132 |
+
| Class ID | Name |
|
| 133 |
+
| --- | --- |
|
| 134 |
+
| 0 | other/background |
|
| 135 |
+
| 1 | invalid |
|
| 136 |
+
| 2 | water |
|
| 137 |
+
| 3 | land |
|
| 138 |
+
| 4 | cloud_shadow |
|
| 139 |
+
| 5 | green_tide |
|
| 140 |
+
| 6 | red_tide |
|
| 141 |
+
| 7 | golden_tide |
|
| 142 |
+
| 8 | aquaculture |
|
| 143 |
+
|
| 144 |
+
When legacy binary masks are imported, they should be represented as task-specific
|
| 145 |
+
labels plus metadata. Do not silently treat unlabeled pixels as true negatives for
|
| 146 |
+
all other ecological elements.
|
| 147 |
+
|
| 148 |
+
## Inventory Rules
|
| 149 |
+
|
| 150 |
+
The inventory scanner should:
|
| 151 |
+
|
| 152 |
+
- Preserve original file paths.
|
| 153 |
+
- Infer element type from directory names and known project folders.
|
| 154 |
+
- Infer satellite/sensor/acquisition date from filenames when possible.
|
| 155 |
+
- Pair image and mask files by stem when masks exist.
|
| 156 |
+
- Record unpaired full-scene images as inference assets.
|
| 157 |
+
- Flag ambiguous data instead of guessing labels.
|
| 158 |
+
|
typical-marine-ecological-feature-recognition-source.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9533c76425b89d40710a2268484d6a9a93683566eb8d465ab7a42307275f1d4c
|
| 3 |
+
size 404413
|