Upload folder using huggingface_hub
Browse files- README.md +83 -0
- config.json +21 -0
- pytorch_model.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Prithvi-2.0 300M - Fine-tuned for Flood Detection (Sen1Floods11)
|
| 2 |
+
|
| 3 |
+
This model is a fine-tuned version of the **Prithvi-2.0 300M** foundation model, specialized for binary flood detection using Sentinel-2 optical imagery.
|
| 4 |
+
|
| 5 |
+
## Model Description
|
| 6 |
+
|
| 7 |
+
- **Developed by:** Tushar Thokdar
|
| 8 |
+
- **Model Type:** Semantic Segmentation
|
| 9 |
+
- **Backbone:** Prithvi-2.0 300M (ViT-Base)
|
| 10 |
+
- **Segmentation Head:** UPerNet
|
| 11 |
+
- **Input Resolution:** 224x224
|
| 12 |
+
- **Input Bands:** 6 (Red, Green, Blue, Narrow NIR, SWIR 1, SWIR 2)
|
| 13 |
+
- **Fine-tuned on:** Sen1Floods11 dataset
|
| 14 |
+
|
| 15 |
+
## Performance Metrics (Official Test Split)
|
| 16 |
+
|
| 17 |
+
Metrics derived from fine-tuning for 80 epochs on the official Sen1Floods11 test split.
|
| 18 |
+
|
| 19 |
+
### Model Metrics
|
| 20 |
+
|
| 21 |
+
| Metric | Fine-Tuned (80 Epochs) | Baseline | Gain (%) |
|
| 22 |
+
| -------------------- | ---------------------- | -------- | -------- |
|
| 23 |
+
| **Flood IoU** | 0.7196 | 0.1339 | +437.3% |
|
| 24 |
+
| **Flood F1** | 0.8370 | 0.2362 | +254.3% |
|
| 25 |
+
| **Flood Precision** | 0.8902 | 0.1638 | +443.4% |
|
| 26 |
+
| **Flood Recall** | 0.7897 | 0.4234 | +86.5% |
|
| 27 |
+
| **Mean IoU** | 0.8396 | 0.3953 | +112.3% |
|
| 28 |
+
| **Overall Accuracy** | 0.9633 | 0.6741 | +42.9% |
|
| 29 |
+
|
| 30 |
+
### Per-Class Metrics (Fine-Tuned)
|
| 31 |
+
|
| 32 |
+
- **No Flood IoU:** 0.9595
|
| 33 |
+
- **No Flood F1:** 0.9793
|
| 34 |
+
- **Flood IoU:** 0.7196
|
| 35 |
+
- **Flood F1:** 0.8370
|
| 36 |
+
|
| 37 |
+
## Training Configuration
|
| 38 |
+
|
| 39 |
+
- **Epochs:** 80
|
| 40 |
+
- **Batch Size:** 16
|
| 41 |
+
- **Learning Rate:** 5e-5
|
| 42 |
+
- **Loss:** Dice (0.5) + Focal (0.5)
|
| 43 |
+
- **Data Splits:** Official (252 Train / 89 Val / 90 Test)
|
| 44 |
+
|
| 45 |
+
## Inference Performance
|
| 46 |
+
|
| 47 |
+
- **Throughput:** 20.66 samples/sec (NVIDIA T4)
|
| 48 |
+
- **Inference Time (Avg):** 0.048s per sample
|
| 49 |
+
|
| 50 |
+
## Usage Instructions
|
| 51 |
+
|
| 52 |
+
To use this model with the `godel-train` library:
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
import torch
|
| 56 |
+
from godel_train.models.factory import ModelFactory
|
| 57 |
+
|
| 58 |
+
# 1. Initialize model with appropriate config
|
| 59 |
+
model = ModelFactory.segmentation(
|
| 60 |
+
backbone="prithvi_eo_v2_300m",
|
| 61 |
+
num_classes=2,
|
| 62 |
+
checkpoint_path="pytorch_model.bin" # Local or downloaded file
|
| 63 |
+
)
|
| 64 |
+
model.eval()
|
| 65 |
+
|
| 66 |
+
# 2. Prepare sample input (Batch, 6 Bands, 224, 224)
|
| 67 |
+
# Bands: Red, Green, Blue, Narrow NIR, SWIR 1, SWIR 2
|
| 68 |
+
sample_input = torch.randn(1, 6, 224, 224)
|
| 69 |
+
|
| 70 |
+
# 3. Run Inference
|
| 71 |
+
with torch.no_grad():
|
| 72 |
+
prediction = model(sample_input)
|
| 73 |
+
# prediction shape: [1, 2, 224, 224] (Logits)
|
| 74 |
+
|
| 75 |
+
mask = torch.argmax(prediction, dim=1)
|
| 76 |
+
# mask shape: [1, 224, 224] (0: No Flood, 1: Flood)
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Data and Credits
|
| 80 |
+
|
| 81 |
+
- **Dataset:** Sen1Floods11
|
| 82 |
+
- **Fine-tuning:** Performed by Tushar Thokdar
|
| 83 |
+
- **Foundation Model:** IBM/NASA Prithvi-2.0
|
config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "prithvi_eo_v2",
|
| 3 |
+
"backbone": "prithvi_eo_v2_300m",
|
| 4 |
+
"num_classes": 2,
|
| 5 |
+
"input_bands": 6,
|
| 6 |
+
"input_size": [224, 224],
|
| 7 |
+
"task": "semantic_segmentation",
|
| 8 |
+
"head": {
|
| 9 |
+
"type": "upernet",
|
| 10 |
+
"pool_scales": [1, 2, 3, 6],
|
| 11 |
+
"fpn_out_channels": 256
|
| 12 |
+
},
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "no_flood",
|
| 15 |
+
"1": "flood"
|
| 16 |
+
},
|
| 17 |
+
"label2id": {
|
| 18 |
+
"no_flood": 0,
|
| 19 |
+
"flood": 1
|
| 20 |
+
}
|
| 21 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5f4e2b6bca8d372b1ef56a981a622af3ecac95903b4ebc1ec636ecb530954fdb
|
| 3 |
+
size 1322509419
|