
# CloudSEN12 trained models


This repository contains the trained models of the publications:

```
@inproceedings{aybar_lessons_2023,
	title = {Lessons {Learned} {From} {Cloudsen12} {Dataset}: {Identifying} {Incorrect} {Annotations} in {Cloud} {Semantic} {Segmentation} {Datasets}},
	url = {https://ieeexplore.ieee.org/document/10282381},
	doi = {10.1109/IGARSS52108.2023.10282381},
	urldate = {2023-10-23},
	booktitle = {{IGARSS} 2023 - 2023 {IEEE} {International} {Geoscience} and {Remote} {Sensing} {Symposium}},
	author = {Aybar, Cesar and Montero, David and Mateo-García, Gonzalo and Gómez-Chova, Luis},
	month = jul,
	year = {2023},
	note = {ISSN: 2153-7003},
	pages = {892--895},
}
@article{aybar_cloudsen12_2022,
	title = {{CloudSEN12}, a global dataset for semantic understanding of cloud and cloud shadow in {Sentinel}-2},
	volume = {9},
	issn = {2052-4463},
	url = {https://www.nature.com/articles/s41597-022-01878-2},
	doi = {10.1038/s41597-022-01878-2},
	number = {1},
	urldate = {2023-01-02},
	journal = {Scientific Data},
	author = {Aybar, Cesar and Ysuhuaylas, Luis and Loja, Jhomira and Gonzales, Karen and Herrera, Fernando and Bautista, Lesly and Yali, Roy and Flores, Angie and Diaz, Lissette and Cuenca, Nicole and Espinoza, Wendy and Prudencio, Fernando and Llactayo, Valeria and Montero, David and Sudmanns, Martin and Tiede, Dirk and Mateo-García, Gonzalo and Gómez-Chova, Luis},
	month = dec,
	year = {2022},
	pages = {782},
}
```

We include the trained models in L1C images:

* **Unet MobileNetV2 all S2 bands** - UNetMobV2_all.pt 
* **Unet MobileNetV2 R-G-B-NIR bands** - UNetMobV2_RGBN.pt
* **ResNet10 all S2 bands** - ResNet10_all.pt


```python
import torch
import tempfile
import segmentation_models_pytorch as smp
from huggingface_hub import hf_hub_url, cached_download

# Load all S2 bands model
tmpfolder = tempfile.TemporaryDirectory()
model_path = hf_hub_url("isp-uv-es/cloudsen12", revision="main", filename="UNetMobV2_all.pt")
output_path = cached_download(model_path, cache_dir=tmpfolder.name)

model = smp.Unet(encoder_name="mobilenet_v2", encoder_weights=None, in_channels=13, classes=4)
weights = torch.load(output_path, map_location=torch.device('cpu'))
model.load_state_dict(weights)
model.eval()


# Load RGBN S2 model
tmpfolder = tempfile.TemporaryDirectory()
model_path = hf_hub_url("isp-uv-es/cloudsen12", revision="main", filename="UNetMobV2_RGBN.jit.pt")
output_path = cached_download(model_path, cache_dir=tmpfolder.name)
```

{"license": "cc-by-nc-4.0", "tags": ["remote sensing", "sentinel2", "clouds"], "pipeline_tag": "image-segmentation"}
remote sensing sentinel2 clouds image-segmentation license:cc-by-nc-4.0 region:us