image imagewidth (px) 1.95k 2.91k |
|---|
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- Background
- What's in each tile (
.npz) - What we already studied: patch-level cloud analysis
- As we can see, UNet and Prithvi Random amlified rubber prediction in cloudy tiles while Prithvi Pretrained doesn't.
- Your task: how does model performance change with region size?
- DICE score (quick reference)
- Tips
- File structure
Mining-Analysis Dataset
A research dataset for error analysis of satellite land-use classifiers, with model predictions, ground truth, RGB imagery, raw spectral bands, and per-month cloud masks. Used in a study of how cloud occlusion affects model predictions of West African land cover (mining, oil palm, rubber).
Background
We use satellite images to detect land-use changes in West Africa — specifically mining sites, oil palm plantations, and rubber plantations. A machine-learning model predicts a class for every pixel of every tile. This dataset bundles model predictions with their ground truth and supporting data so the structure of the model's errors can be studied.
Classes
| Value | Class |
|---|---|
| 0 | Everything else (forest, water, buildings, etc.) |
| 1 | Oil palm plantation |
| 2 | Rubber plantation |
| 3 | Mining |
| -1 | Ignore (no label available) |
Models included
The data/ directory has three model folders, each containing the same set of test-set tiles:
| Folder | Model | Notes |
|---|---|---|
data/prithvi_pretrained/ |
Prithvi-EO-V2 300M with pretrained backbone, fine-tuned on this task | Strong baseline |
data/prithvi_random/ |
Same Prithvi architecture but the backbone weights are randomly initialised | Tests whether pretraining helps vs. training from scratch |
data/unet/ |
3D U-Net trained from scratch | Convolutional baseline (no transformer) |
What's in each tile (.npz)
Each file at data/<model>/<tile>.npz has five arrays:
| Key | Shape | dtype | Description |
|---|---|---|---|
pred |
(224, 224) | int8 | The model's predicted class per pixel |
gt |
(224, 224) | int8 | Ground-truth class per pixel (-1 = unlabelled) |
rgb |
(224, 224, 3) | uint8 | RGB median composite for display |
spectral |
(6, 7, 224, 224) | float16 | Raw 6-band × 7-month spectral cube |
clarity |
(7, 224, 224) | uint8 | Per-month cloud mask (1 = clear-ish, 0 = cloudy) |
Spectral bands
| Index | Band | Wavelength | What it captures |
|---|---|---|---|
| 0 | Blue | 0.45–0.51 µm | Water, atmosphere |
| 1 | Green | 0.53–0.59 µm | Vegetation vigour |
| 2 | Red | 0.64–0.67 µm | Chlorophyll absorption |
| 3 | NIR | 0.85–0.88 µm | Healthy vegetation |
| 4 | SWIR1 | 1.57–1.65 µm | Soil & moisture |
| 5 | SWIR2 | 2.11–2.29 µm | Minerals, bare soil |
The 7 monthly composites are from Jan, Feb, Mar, Apr, May, Nov, Dec.
Loading
import numpy as np, os
data_dir = "data/prithvi_pretrained"
tile = np.load(os.path.join(data_dir, "r049_c156.npz"))
pred, gt = tile["pred"], tile["gt"]
rgb = tile["rgb"]
spectral = tile["spectral"] # (6 bands, 7 months, 224, 224)
clarity = tile["clarity"] # (7 months, 224, 224) -- 1 = clear-ish, 0 = cloudy
What we already studied: patch-level cloud analysis
The motivating question: does cloud occlusion hurt some land-cover classes more than others?
West Africa has a long cloudy season (June–October) and the input composites still contain residual cloud contamination after gap-filling. If clouds disproportionately confuse the model for, say, mining (which has bright bare-soil spectra similar to clouds), that has consequences for downstream monitoring.
Approach
For each test tile we slice it into non-overlapping P × P patches (we used P=32 and P=64), and per patch we compute:
cloud_frac— the fraction of pixel-months that were cloudy- per-class pixel counts (from GT and from each model's prediction)
Then we look at:
- Distribution of patches by cloud fraction, split by class
- How predicted prevalence and FPR shift across cloud bins, per model
Findings
(1) Patch-level cloud-fraction distribution per class (P=64):
The histogram is heavy on the right — most patches of rubber are fairly cloudy..
(2) Class shift as cloud fraction varies (Rubber, P=32):
Left: predicted rubber prevalence per cloud-fraction bin, per model, with the GT prevalence line. Right: conditional false-positive rate for rubber per cloud bin.
Key Lessions: Prithvi matches the GT cloud prevalence while Unet and Prithvi non pretrained amplifies the bias (more cloud, more rubber). This is further reflcted in the FPR metric on theright where more clouds --> more pixels misclassified as rubber.
(3) Qualitative examples — cloudy vs clear rubber patches (P=32):
Eight 32×32 patches sampled from the test set, all with ≥30% rubber in the ground truth. The top four rows are cloudy patches (cloud fraction in [0.6, 1.0]) and the bottom four rows are clear patches (cloud fraction in [0.0, 0.4]). Each row shows: the 7 monthly RGB frames (t0–t6), the GT mask, and each model's prediction. Mask colors are gray=everything else, green=oil palm, yellow=rubber, red=mining.
As we can see, UNet and Prithvi Random amlified rubber prediction in cloudy tiles while Prithvi Pretrained doesn't.
Your task: how does model performance change with region size?
A single DICE number per class is an average across regions of every size — a few tiny clearings get averaged together with one giant plantation. That hides whether a model is good at finding small plantations vs large ones.
The question
For each class, how does each model's accuracy change as the region size changes?
Approach
For each test tile and each target class c ∈ {1: oil palm, 2: rubber, 3: mining}:
- Run connected-component labelling on the ground truth:
scipy.ndimage.label(gt == c, structure=np.ones((3,3))). Each connected component is one "region" of classc. - For each region, record its size in pixels and compute each model's per-region IoU:
region_mask = (labels == region_id) tp = ((pred == c) & region_mask).sum() fp = ((pred == c) & ~region_mask).sum() fn = ((pred != c) & region_mask).sum() iou = tp / (tp + fp + fn) - Collect all regions across all tiles into a table with one row per region:
(tile, class, region_id, size_pixels, iou_prithvi_pretrained, iou_prithvi_random, iou_unet) - Bin regions by size (e.g., 1–10 px, 10–50, 50–200, 200–1000, 1000+) and compute the mean IoU per bin per model.
Deliverables we'd love to see
- A line plot per class: x-axis = region size bin, y-axis = mean IoU, one line per model. Answers "which model is best at small/medium/large regions?"
- A summary table of region counts per size bin per class — so we know how many examples each bin is built from.
- A side-by-side viewer for "interesting" regions: pick a few examples where the models disagree the most and show RGB + GT + each model's prediction zoomed to the region.
- (Stretch) Same analysis but on PREDICTED regions instead of GT regions — answers a different question: "when each model predicts a region of size X, how often is it right?"
Hints
- Components smaller than ~5 pixels are mostly classification noise. Filter them out at the start.
- Class 3 (mining) has very few regions overall — use log-scale bins or merge bins so you have enough samples per bin.
scipy.ndimage.find_objectsreturns a bounding box per region — handy for cropping the viewer.- The result table fits in a Pandas DataFrame — easier than juggling arrays.
Why three models
The three models give two interesting axes of comparison:
- prithvi_pretrained vs prithvi_random — what does pretraining contribute?
- prithvi_pretrained vs unet — what does the transformer architecture contribute vs a convnet?
DICE score (quick reference)
DICE = 2·TP / (2·TP + FP + FN)
Where TP/FP/FN are computed per-class. Range: 0 (no overlap) to 1 (perfect). DICE = F1 when applied at the pixel level.
Tips
- Always filter
gt == -1(unlabelled) pixels out of metric computations. - Use coding assistants (like Claude) to help write the analysis code — give them this README as context.
- Start small: pick one tile, one class, one model, get IoU per component working. Then loop.
- The dataset is ~2 GB. Keep intermediate per-component statistics in a Pandas DataFrame; don't keep all the spectral cubes in memory at once.
File structure
data/
prithvi_pretrained/
<tile_1>.npz
<tile_2>.npz
...
prithvi_random/
...
unet/
...
docs/
cloud_class_hist_patch64.png
continuous_patch32_class2_rubber.png
README.md
- Downloads last month
- 492


