Update English model card
Browse files
README.md
CHANGED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
-
license: apache-2.0
|
| 6 |
tags:
|
| 7 |
- OneScience
|
| 8 |
- Earth Science
|
| 9 |
-
- Remote Sensing
|
| 10 |
-
- Masked
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
-
|
| 14 |
-
|
| 15 |
-
datasets: []
|
| 16 |
---
|
|
|
|
| 17 |
<p align="center">
|
| 18 |
<strong>
|
| 19 |
<span style="font-size: 30px;">SpectralGPT</span>
|
|
@@ -22,50 +21,48 @@ datasets: []
|
|
| 22 |
|
| 23 |
# Model Introduction
|
| 24 |
|
| 25 |
-
SpectralGPT
|
| 26 |
-
|
| 27 |
-
Paper: SpectralGPT: Spectral Remote Sensing Foundation Model
|
| 28 |
|
|
|
|
| 29 |
https://arxiv.org/abs/2311.07113
|
| 30 |
|
| 31 |
# Model Description
|
| 32 |
|
| 33 |
-
SpectralGPT was proposed by
|
| 34 |
|
| 35 |
# Use Cases
|
| 36 |
|
| 37 |
| Scenario | Description |
|
| 38 |
| :---: | :--- |
|
| 39 |
-
|
|
| 40 |
-
|
|
| 41 |
-
|
|
| 42 |
-
|
|
| 43 |
-
|
|
|
|
|
| 44 |
|
| 45 |
# Usage Guide
|
| 46 |
|
| 47 |
-
## 1. OneCode
|
| 48 |
|
| 49 |
Experience intelligent one-click AI4S programming through the OneCode online environment:
|
| 50 |
|
| 51 |
[Click to Experience Intelligent One-Click AI4S Programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
|
| 52 |
|
| 53 |
-
## 2.
|
| 54 |
-
|
| 55 |
-
**Hardware Requirements**
|
| 56 |
-
|
| 57 |
-
- A GPU or DCU is recommended.
|
| 58 |
-
- CPU can be used for import and small-scale connectivity verification; full training and inference will be slower.
|
| 59 |
-
- DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching the cluster, is recommended.
|
| 60 |
-
|
| 61 |
-
### Download the Model Package
|
| 62 |
|
| 63 |
```bash
|
| 64 |
hf download OneScience-Group/SpectralGPT --local-dir ./SpectralGPT
|
| 65 |
cd SpectralGPT
|
| 66 |
```
|
| 67 |
|
| 68 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
**DCU Environment**
|
| 71 |
|
|
@@ -89,69 +86,58 @@ pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simp
|
|
| 89 |
|
| 90 |
### Training Data Introduction
|
| 91 |
|
| 92 |
-
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
```text
|
| 97 |
-
Official Zenodo page:
|
| 98 |
-
https://zenodo.org/records/7711810
|
| 99 |
-
|
| 100 |
-
Multispectral data download:
|
| 101 |
-
https://madm.dfki.de/files/sentinel/EuroSATallBands.zip
|
| 102 |
-
```
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
-
```
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
```
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
### Training
|
| 113 |
-
|
| 114 |
-
Local quick validation with synthetic data:
|
| 115 |
|
| 116 |
```bash
|
| 117 |
python scripts/fake_data.py
|
| 118 |
-
python scripts/train.py
|
| 119 |
```
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
```bash
|
| 124 |
-
python scripts/fake_data.py --real-dir ./data/EuroSAT_MS
|
| 125 |
-
python scripts/train.py
|
| 126 |
-
```
|
| 127 |
-
|
| 128 |
-
Synthetic and real data use the same training script. Adjust `data.samples`, `model.image_size`, `training.epochs`, and `training.batch_size` in `conf/config.yaml` as needed.
|
| 129 |
-
|
| 130 |
-
Single GPU or CPU:
|
| 131 |
|
| 132 |
```bash
|
| 133 |
python scripts/train.py
|
| 134 |
```
|
| 135 |
|
| 136 |
-
|
| 137 |
|
| 138 |
```bash
|
| 139 |
-
torchrun --nproc_per_node=8
|
| 140 |
```
|
| 141 |
|
| 142 |
-
Training
|
| 143 |
|
| 144 |
```text
|
| 145 |
-
result/checkpoints/
|
| 146 |
-
result/checkpoints/
|
| 147 |
-
|
|
|
|
| 148 |
```
|
| 149 |
|
| 150 |
-
The `data_source` and `protocol` fields in the training logs and checkpoints identify whether synthetic or real data was used. Checkpoints generated from synthetic data are only for pipeline validation and do not provide real remote sensing representations.
|
| 151 |
-
|
| 152 |
### Training Weights
|
| 153 |
|
| 154 |
-
|
| 155 |
|
| 156 |
### Inference
|
| 157 |
|
|
@@ -159,9 +145,7 @@ Multispectral Sentinel-2 training weights will be provided under `weight/` in a
|
|
| 159 |
python scripts/inference.py
|
| 160 |
```
|
| 161 |
|
| 162 |
-
Inference
|
| 163 |
-
|
| 164 |
-
Prediction output:
|
| 165 |
|
| 166 |
```text
|
| 167 |
result/output/reconstruction.npz
|
|
@@ -173,15 +157,13 @@ result/output/reconstruction.npz
|
|
| 173 |
python scripts/result.py
|
| 174 |
```
|
| 175 |
|
| 176 |
-
Evaluation and
|
| 177 |
|
| 178 |
```text
|
| 179 |
result/output/metrics.json
|
| 180 |
-
result/output/reconstruction.
|
| 181 |
```
|
| 182 |
|
| 183 |
-
The metrics include reconstruction MSE, MAE, PSNR, and per-band RMSE. The visualization displays input and reconstructed false-color composites. Synthetic data is used only to confirm that the evaluation and visualization pipeline runs successfully; its numerical values are not reported as model performance. Real-data metrics represent masked reconstruction on the user-provided imagery.
|
| 184 |
-
|
| 185 |
# Official OneScience Resources
|
| 186 |
|
| 187 |
| Platform | OneScience Main Repository | Skills Repository |
|
|
@@ -191,5 +173,6 @@ The metrics include reconstruction MSE, MAE, PSNR, and per-band RMSE. The visual
|
|
| 191 |
|
| 192 |
# Citation and License
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: gpl-3.0
|
| 3 |
language:
|
| 4 |
- en
|
|
|
|
| 5 |
tags:
|
| 6 |
- OneScience
|
| 7 |
- Earth Science
|
| 8 |
+
- Hyperspectral Remote Sensing
|
| 9 |
+
- Masked Autoencoder
|
| 10 |
+
frameworks: PyTorch
|
| 11 |
+
datasets:
|
| 12 |
+
- fMoW-Sentinel
|
| 13 |
+
- BigEarthNet
|
|
|
|
| 14 |
---
|
| 15 |
+
|
| 16 |
<p align="center">
|
| 17 |
<strong>
|
| 18 |
<span style="font-size: 30px;">SpectralGPT</span>
|
|
|
|
| 21 |
|
| 22 |
# Model Introduction
|
| 23 |
|
| 24 |
+
SpectralGPT is a foundation model for spectral remote sensing imagery. It learns cross-band and spatial structures through spatial-spectral 3D patching, masked autoencoding, and progressive pretraining, and can provide representations for tasks such as classification, segmentation, and change detection.
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
Paper: SpectralGPT: Spectral Remote Sensing Foundation Model
|
| 27 |
https://arxiv.org/abs/2311.07113
|
| 28 |
|
| 29 |
# Model Description
|
| 30 |
|
| 31 |
+
SpectralGPT was proposed by a research team from Northwestern Polytechnical University and other institutions. The model is first trained on `96x96` fMoW-Sentinel data and then performs second-stage progressive pretraining on `128x128` BigEarthNet data. It is suitable for multispectral image reconstruction, spectral remote sensing representation learning, and transfer to downstream remote sensing tasks.
|
| 32 |
|
| 33 |
# Use Cases
|
| 34 |
|
| 35 |
| Scenario | Description |
|
| 36 |
| :---: | :--- |
|
| 37 |
+
| Progressive pretraining | Sequentially perform `96x96` first-stage and `128x128` second-stage training. |
|
| 38 |
+
| Spatial-spectral reconstruction | Perform masked reconstruction of 12-band spatial-spectral Sentinel-2 patches. |
|
| 39 |
+
| Multispectral land-cover classification | Transfer spatial-spectral representations and fine-tune for land-cover classification on datasets such as EuroSAT and BigEarthNet. |
|
| 40 |
+
| Semantic segmentation and change detection | Adapt the pretrained encoder to pixel-level land-cover segmentation and bi-temporal remote sensing change detection tasks. |
|
| 41 |
+
| Local engineering validation | Use a small amount of synthetic data to check the training, inference, and evaluation workflows. |
|
| 42 |
+
| Multi-GPU training | Launch distributed training with `torchrun`. |
|
| 43 |
|
| 44 |
# Usage Guide
|
| 45 |
|
| 46 |
+
## 1. OneCode
|
| 47 |
|
| 48 |
Experience intelligent one-click AI4S programming through the OneCode online environment:
|
| 49 |
|
| 50 |
[Click to Experience Intelligent One-Click AI4S Programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
|
| 51 |
|
| 52 |
+
## 2. Download and Installation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
```bash
|
| 55 |
hf download OneScience-Group/SpectralGPT --local-dir ./SpectralGPT
|
| 56 |
cd SpectralGPT
|
| 57 |
```
|
| 58 |
|
| 59 |
+
### Environment Dependencies
|
| 60 |
+
|
| 61 |
+
**Hardware Requirements**
|
| 62 |
+
|
| 63 |
+
- A GPU or DCU is recommended.
|
| 64 |
+
- CPU can be used for small-configuration connectivity validation; full training and inference will be slow.
|
| 65 |
+
- DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching the current cluster, is recommended.
|
| 66 |
|
| 67 |
**DCU Environment**
|
| 68 |
|
|
|
|
| 86 |
|
| 87 |
### Training Data Introduction
|
| 88 |
|
| 89 |
+
By default, a small amount of synthetic data is used to validate the two-stage engineering workflow. The first stage uses fMoW-Sentinel-style samples, and the second stage uses BigEarthNet-style samples.
|
| 90 |
|
| 91 |
+
The synthetic data preserves the official progressive pretraining input specifications of 12 bands, `96x96` in the first stage, and `128x128` in the second stage.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
Real data must be preprocessed and converted to the following NPZ training protocol. This protocol is consistent with the model input specification but is not the download format of the original datasets.
|
| 94 |
|
| 95 |
+
```text
|
| 96 |
+
stage1:
|
| 97 |
+
images: float32 [N,12,96,96]
|
| 98 |
+
band_order: string [12]
|
| 99 |
+
normalization: string scalar
|
| 100 |
+
scale_factors: float32 [N]
|
| 101 |
+
stage: string scalar = stage1
|
| 102 |
+
|
| 103 |
+
stage2:
|
| 104 |
+
images: float32 [N,12,128,128]
|
| 105 |
+
band_order: string [12]
|
| 106 |
+
normalization: string scalar
|
| 107 |
+
scale_factors: float32 [N]
|
| 108 |
+
stage: string scalar = stage2
|
| 109 |
```
|
| 110 |
|
| 111 |
+
`fake_data.py` automatically writes the `protocol` and `data_source` protocol metadata. These fields must be retained when using real data.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
```bash
|
| 114 |
python scripts/fake_data.py
|
|
|
|
| 115 |
```
|
| 116 |
|
| 117 |
+
### Training
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
```bash
|
| 120 |
python scripts/train.py
|
| 121 |
```
|
| 122 |
|
| 123 |
+
For multi-GPU training, use:
|
| 124 |
|
| 125 |
```bash
|
| 126 |
+
torchrun --nproc_per_node=8 scripts/train.py
|
| 127 |
```
|
| 128 |
|
| 129 |
+
Training first completes the 96-size first stage, then interpolates the spatial positional encoding and completes the 128-size second stage, saving stage checkpoints, a final checkpoint, and aggregate training metrics. The default configuration is intended for quick workflow validation. Formal experiments should use the two-stage data scale, model configuration, and training duration corresponding to the paper.
|
| 130 |
|
| 131 |
```text
|
| 132 |
+
result/checkpoints/stage1.pth
|
| 133 |
+
result/checkpoints/stage2.pth
|
| 134 |
+
result/checkpoints/final.pth
|
| 135 |
+
result/training/metrics.json
|
| 136 |
```
|
| 137 |
|
|
|
|
|
|
|
| 138 |
### Training Weights
|
| 139 |
|
| 140 |
+
This repository will provide SpectralGPT training weights in the `weight/` folder. The weight files will be uploaded soon and are expected to be available in the near future.
|
| 141 |
|
| 142 |
### Inference
|
| 143 |
|
|
|
|
| 145 |
python scripts/inference.py
|
| 146 |
```
|
| 147 |
|
| 148 |
+
Inference loads the final second-stage checkpoint, performs masked reconstruction on the `128x128` test data, and saves the results to:
|
|
|
|
|
|
|
| 149 |
|
| 150 |
```text
|
| 151 |
result/output/reconstruction.npz
|
|
|
|
| 157 |
python scripts/result.py
|
| 158 |
```
|
| 159 |
|
| 160 |
+
Evaluation reports masked-region MSE, MAE, PSNR, spectral angle, and per-band RMSE, and generates a figure containing the input, visible region, prediction, and composite result. Results on synthetic data are only for engineering workflow validation and do not represent full-paper performance.
|
| 161 |
|
| 162 |
```text
|
| 163 |
result/output/metrics.json
|
| 164 |
+
result/output/reconstruction.png
|
| 165 |
```
|
| 166 |
|
|
|
|
|
|
|
| 167 |
# Official OneScience Resources
|
| 168 |
|
| 169 |
| Platform | OneScience Main Repository | Skills Repository |
|
|
|
|
| 173 |
|
| 174 |
# Citation and License
|
| 175 |
|
| 176 |
+
This repository is a reproduction of the original SpectralGPT paper.
|
| 177 |
+
|
| 178 |
+
Use of the code and data in this repository remains subject to the licenses and terms of use of their respective projects.
|