Skip to main content

Welcome to CloudS2Mask ☁️

GitHub Version Last Commit

💡 About

CloudS2Mask is an open-source Python library that efficiently segments clouds and cloud shadows in Sentinel-2 imagery using state-of-the-art deep learning techniques.

🎯 Features

  • High-precision cloud and cloud shadow segmentation for Sentinel-2 L1C imagery.
  • Rapid processing: Approximately 2.2 seconds per scene at 20m resolution (RTX 4090, AMD Ryzen 9 5950X).
  • Compatibility with both GPU and non-GPU systems.
  • Supported on Linux, Windows, and macOS.

🚀 Installation

Windows Users with NVIDIA GPUs: Before installing CloudS2Mask, ensure you've installed PyTorch with CUDA support, then follow the steps below.

Mac and Linux Users: You can proceed with the installation commands below.

To install using pip.

pip install clouds2mask

Or manually.

git clone https://github.com/DPIRD-DMA/CloudS2Mask
cd CloudS2Mask
pip install -q .
cd ..

💻 Usage

Here's a simple demonstration of how to use CloudS2Mask:

All you need to do is pass a list of Sentinel-2 level 1C 'SAFE' directories to CloudS2Mask.

Colab_Button

from pathlib import Path
from clouds2mask import (
    create_settings,
    batch_process_scenes,
)

output_dir = Path("./outputs")
l1c_folders_path = Path("/path/to/your/S2_l1c_SAFE/folders")
l1c_folders = list(l1c_folders_path.glob("*.SAFE"))


scene_settings = create_settings(
    sent_safe_dirs=l1c_folders,
    output_dir=output_dir,
    processing_res=20,
)

paths_to_masks = batch_process_scenes(scene_settings)

⚙️ Performance Tuning

CloudsS2Mask offers a range of performance and accuracy options, here are some examples,

Settings for high accuracy inference:

scene_settings = create_settings(
    sent_safe_dirs=l1c_folders,
    output_dir=output_dir,
    batch_size=32,
    tta_max_depth=2,
    processing_res=10,
    model_ensembling=True,
)

Settings for fast inference:

scene_settings = create_settings(
    sent_safe_dirs=l1c_folders,
    output_dir=output_dir,
    batch_size=32,
    processing_res=20,
    output_compression=None,
)

Settings for CPU inference:

scene_settings = create_settings(
    sent_safe_dirs=l1c_folders,
    output_dir=output_dir,
    batch_size=1,
    processing_res=20,
)

CloudS2Mask will try to auto detect acceleration cards such as NVIDIA GPUs or Apple MPS, but you can also manually specify them like this:

scene_settings = create_settings(
    sent_safe_dirs=l1c_folders,
    output_dir=output_dir,
    pytorch_device='MPS',
)

👏 Contributing

We welcome all contributions! Feel free to open an issue or submit a pull request.

📄 License

This project is licensed under the MIT License - please refer to the LICENSE file for more details.

📝 Contact

For support, bug reporting, or to contribute, feel free to reach out at nicholas.wright@dpird.wa.gov.au.

Metadata

Release files for clouds2mask 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clouds2mask 1.1.3
File Size Uploaded
clouds2mask-1.1.3.tar.gz 25.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clouds2mask 1.1.3
File Interpreter ABI Platform
clouds2mask-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 55.1 kB

Release files / clouds2mask-1.1.3.tar.gz

Download URL clouds2mask-1.1.3.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7adfd34d1b6cbf1d855cd862fd07053bcafc73b41e7a3759cc50fdc4e9e4570e
BLAKE2b-256 checksum
How to use checksums
83b3d99610981742332d38983eed1451f35ec0dff1264f71ecffbd3fdc7e0cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release files / clouds2mask-1.1.3-py3-none-any.whl

Download URL clouds2mask-1.1.3-py3-none-any.whl
Size 29.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d662da5f5e89e7ccb20271aef6766e7f0e16a78628e4118c26959e41dbbbeb5
BLAKE2b-256 checksum
How to use checksums
fbc25b1e8044c54f33178723f553376e1f49d4b3ed968bc9631efbb8bb110d2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page