ftp-b7 / README.md
isaaccorley's picture
Upload README.md with huggingface_hub
ff9851f verified
|
Raw
History Blame Contribute Delete
4.6 kB
---
license: cc-by-nc-4.0
tags:
- remote-sensing
- segmentation
- field-boundary-delineation
- agriculture
- planetscope
- pytorch-lightning
- onnx
- semantic-segmentation
library_name: pytorch
pipeline_tag: image-segmentation
---
# FTP-PRUE+ (EfficientNet-B7) β€” Fields of the Planet
3m PlanetScope field-boundary segmentation model from **Fields of the Planet
(FTP)**, a PlanetScope companion to [Fields of the World v2
(FTW)](https://github.com/fieldsoftheworld/ftw-baselines). Larger-backbone
variant of the paper's headline model ([`ftp-b3`](https://huggingface.co/taylor-geospatial/ftp-b3)).
U-Net decoder over an EfficientNet-B7 encoder, trained on paired early- and
peak-season PlanetScope surface-reflectance imagery (8 input channels: 2
seasonal windows x 4 bands) to predict a 3-class field mask (background /
field / boundary) at 3m ground sample distance.
- **Repo:** [taylor-geospatial/ftw-planet](https://github.com/taylor-geospatial/ftw-planet)
- **Paper:** Fields of the Planet: Field Boundary Mapping Beyond 10m
- **Architecture:** `smp.Unet(encoder_name="efficientnet-b7")`, `in_channels=8`, `classes=3`
- **Training resolution:** 512x512 crops, 3m/px
- **Loss:** log-cosh Dice, class weights `[0.05, 0.2, 0.75]`, `ignore_index=3`
- **Recipe:** PRUE+ (geometry/noise augmentations, watershed post-processing, D4 TTA at eval)
## Files
| File | Format | Notes |
|---|---|---|
| `config.json` + `model.safetensors` | `segmentation_models_pytorch` Hub format | recommended for most users β€” safetensors (no pickle), self-describing architecture, needs only `pip install segmentation-models-pytorch` |
| `ftp-b7.ckpt` | PyTorch Lightning checkpoint | `state_dict` + `hyper_parameters` only β€” optimizer/scheduler state stripped |
| `ftp-b7.onnx` | ONNX (opset 17) | single-file, dynamic batch/H/W, needs `onnxruntime` (plain PyTorch cannot execute `.onnx`) |
| `ftp-b7.pt2` | `torch.export` ExportedProgram | standalone, dynamic batch / static 512x512, loads with `torch.export.load` β€” no `ftw_planet` install needed |
## Usage
### segmentation_models_pytorch (recommended)
```python
import segmentation_models_pytorch as smp
model = smp.from_pretrained("taylor-geospatial/ftp-b7").eval()
logits = model(image) # image: (B, 8, H, W) float32, 2 seasonal windows x 4 bands
```
### Lightning checkpoint (raw `smp.Unet`)
The checkpoint's `state_dict` is just an `smp.Unet` under a `model.` prefix β€”
unless you need the Lightning training wrapper, `smp.from_pretrained` above
is simpler.
```python
import torch
import segmentation_models_pytorch as smp
ckpt = torch.load("ftp-b7.ckpt", map_location="cpu")
hp = ckpt["hyper_parameters"]
model = smp.Unet(encoder_name=hp["backbone"], encoder_weights=None, in_channels=hp["in_channels"], classes=hp["num_classes"])
model.load_state_dict({k.removeprefix("model."): v for k, v in ckpt["state_dict"].items()})
model.eval()
logits = model(image) # image: (B, 8, H, W) float, 2 seasonal windows x 4 bands
```
### ONNX
```python
import onnxruntime as ort
sess = ort.InferenceSession("ftp-b7.onnx", providers=["CPUExecutionProvider"])
logits = sess.run(None, {"image": image_np})[0] # image_np: (B, 8, H, W) float32
```
### torch.export (standalone, no `ftw_planet` needed)
```python
import torch
exported = torch.export.load("ftp-b7.pt2")
model = exported.module()
logits = model(image) # image: (B, 8, 512, 512) float32, any batch size
```
Output is 3-class logits (background / field / boundary); argmax + the
repo's watershed post-processing (`scripts/eval/postprocess_eval.py`)
recovers instance polygons.
## Results
Macro-averaged over the 10 dense held-out FTW-v2 countries, true-polygon
scoring at native 3m GSD (see paper Table 1): PQ 35.4, SQ 74.4, RQ 46.1,
F1 27.0, matched-boundary error 7.4m (mean) / 22.8m (p95), pixel IoU 74.2,
PQ by GT size β€” small 15.6 / medium 40.6 / large 50.9.
The B3 variant scores marginally higher PQ (35.5 vs 35.4) at ~5x fewer
parameters; B7 trades that for better pixel IoU (74.2 vs 68.8) and
medium-field PQ (40.6 vs 39.2).
## Citation
```bibtex
@misc{ftw-planet,
author = {Corley, Isaac and Robinson, Caleb and Marcus, Jennifer and Kerner, Hannah},
title = {Fields of the Planet: Field Boundary Mapping Beyond 10m},
year = {2026},
url = {https://github.com/taylor-geospatial/ftw-planet}
}
```
## License
Weights: CC-BY-NC-4.0. Trained on PlanetScope imagery (c) Planet Labs PBC,
exported under the NICFI / research program, and FTW v2 polygons (CC-BY-4.0).
Refer to those source terms for any redistribution of the underlying data.