skema-kelp


Nameskema-kelp JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummarySatellite-based kelp classification from Sentinel-2 using semantic segmentation
upload_time2025-10-31 00:37:40
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.8
licenseMIT
keywords kelp sentinel-2 semantic-segmentation remote-sensing satellite-imagery deep-learning pytorch
VCS
bugtrack_url
requirements torch torchvision pytorch-lightning segmentation-models-pytorch torchmetrics albumentations numpy pandas scikit-learn scipy matplotlib tifffile rasterio cppy kiwisolver tqdm click
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SKeMa
[![DOI](https://img.shields.io/badge/DOI-10.57967%2Fhf%2F6790-blue)](https://doi.org/10.57967/hf/6790)
[![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-SKeMa-yellow)](https://huggingface.co/m5ghanba/SKeMa)
[![PyPI](https://img.shields.io/pypi/v/skema-kelp)](https://pypi.org/project/skema-kelp/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Model License: CC BY 4.0](https://img.shields.io/badge/Model%20License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)

**Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery**

`skema` is a Python tool for classifying kelp in Sentinel-2 satellite images using a deep learning segmentation model (PyTorch). It provides a command-line interface (CLI) for easy, reproducible inference. To run the tool you would need to download Sentinel-2 images from the Copernicus Browser. More detailed instruction on how to download these images can be found in Section Usage. The following instructions are provided for anyone with no knowledge of what a command line is, no knowledge of Python or virtual environments, etc. Just follow along step by step.

**Model available on Hugging Face**: [m5ghanba/SKeMa](https://huggingface.co/m5ghanba/SKeMa)  
**DOI**: [10.57967/hf/6790](https://doi.org/10.57967/hf/6790)

---

## ⚡ Quick Start (Experienced Users)
```bash
pip install skema-kelp

# Download static files (for model_full only) from sources listed below
# Download Sentinel-2 imagery from https://dataspace.copernicus.eu/browser/

skema --input-dir path/to/S2_scene.SAFE --output-filename output.tif

# For help and all options
skema --help
```

**For detailed installation instructions (beginner-friendly), see [Installation](#-installation) below.**

---

## Citation

If you use **SKeMa** in your research or work, please cite:

```bibtex
@software{skema_2025,
  author       = {Mohsen Ghanbari et al.},
  title        = {SKeMa: Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery},
  year         = 2025,
  publisher    = {Hugging Face},
  doi          = {10.57967/hf/6790},
  url          = {https://huggingface.co/m5ghanba/SKeMa}
}
```

**Plain text**:  
Ghanbari, M., et al. (2025). *SKeMa: Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery*. Hugging Face. https://doi.org/10.57967/hf/6790

---

## 🚀 Installation

Before you can set up SKeMa, you'll need **Python** (version 3.8 or higher) installed on your computer. Python is a free tool, and no accounts or sign-ups are required to install it. We'll install it using your terminal (command line) where possible for simplicity. If you're on Windows, ensure you're using **PowerShell** or **Command Prompt** as Administrator (right-click and select "Run as administrator") for some steps.

### Step 1: Install Python

#### On Windows
1. **Check if Winget is available** (it's built into Windows 10 version 2009 or later, or Windows 11, and most modern systems have it):
   - Open PowerShell or Command Prompt.
   - Type `winget --version` and press Enter.
   - If it shows a version number (e.g., "v1.8.0"), proceed. If not (error like "winget is not recognized"), download the App Installer from the Microsoft Store (search for "App Installer") or update Windows via Settings > Update & Security > Windows Update.

2. **Install Python 3.12** (the latest stable version as of October 2025; this meets the >=3.8 requirement):
   - In your terminal, run:
     ```
     winget install -e --id Python.Python.3.12
     ```
   - This downloads and installs Python automatically. It may take a few minutes.
   - **Important**: During installation (if prompted), ensure "Add Python to PATH" is selected (it usually is by default with winget).
   - Restart your terminal after installation.
   - Verify: Run `python --version`. It should output something like "Python 3.12.7". If not, close and reopen the terminal, or manually add Python to PATH (search online for "add Python to PATH Windows").

   *Alternative if winget fails*: Download the installer from [python.org](https://www.python.org/downloads/windows/) using your browser, run it, and follow the GUI prompts (make sure to check "Add Python to PATH"). Then verify as above.

#### On macOS
1. **Install Homebrew** (a package manager for CLI installations, if you don't have it):
   - Open Terminal (search for it in Spotlight with Cmd+Space).
   - Run:
     ```
     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
     ```
   - Follow any on-screen prompts (it may ask for your password; this is normal). No account needed.
   - After installation, run the commands it suggests to add Homebrew to your PATH (e.g., `echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile` and then `eval "$(/opt/homebrew/bin/brew shellenv)"`).
   - Verify: Run `brew --version`. It should show a version like "4.3.0".

2. **Install Python 3.12**:
   - Run:
     ```
     brew install python@3.12
     ```
   - This installs Python and adds it to PATH.
   - Verify: Run `python3 --version` (note: use `python3` on macOS). It should output "Python 3.12.7".

   *Alternative*: Download the official installer from [python.org](https://www.python.org/downloads/macos/) using your browser, run it, and follow GUI steps.

#### On Linux (e.g., Ubuntu/Debian; adjust for other distros like Fedora)
1. **Update your package list**:
   - Open your terminal.
   - Run:
     ```
     sudo apt update
     ```
   - Enter your password when prompted (sudo is for admin privileges; no account needed beyond your user login).

2. **Install Python 3.12**:
   - Run:
     ```
     sudo apt install python3.12 python3.12-venv python3-pip
     ```
   - This installs Python, the venv module, and pip.
   - Verify: Run `python3 --version`. It should output "Python 3.12.x".
   - *For Fedora/RHEL*: Use `sudo dnf install python3.12` instead.

   *Note*: If your distro's repositories don't have Python 3.12, add a PPA (e.g., for Ubuntu: `sudo add-apt-repository ppa:deadsnakes/ppa` then update and install).

Once Python is installed and verified, proceed to the next section. If you encounter errors (e.g., "command not found"), search online for the exact error message + your OS.

### Step 2: Install SKeMa

Open your **terminal**:  
- On **Windows**, you can use Command Prompt or PowerShell.  
- On **macOS**, open the Terminal app.  
- On **Linux**, open your terminal emulator of choice.  

When you open a terminal, you start inside a **directory (folder)**. You can move to another directory with the command `cd`. For example:  

```  
cd C:\Users\YourName\Documents  
```  

On macOS/Linux:  

```  
cd /Users/yourname/Documents  
```  

👉 The easiest way to navigate is to open your file explorer, go to the folder you want, then copy its full path and paste it after `cd` on the command line. For more details, look up "basic terminal navigation" online.  

Now, navigate to a directory where you want to work with SKeMa, then run:

#### Option 1: Install with pip (Recommended)

```bash
# Create a virtual environment (optional but recommended)
python -m venv skema_env

# Activate the virtual environment
# On Windows:
skema_env\Scripts\activate
# On macOS/Linux:
source skema_env/bin/activate

# Install SKeMa
pip install skema-kelp
```

#### Option 2: Install from source (for developers)

If you want to modify the code or contribute to development:

```bash
# Install Git first (see system-specific instructions below)
# Then clone the repository
git clone https://github.com/m5ghanba/skema.git
cd skema

# Create and activate virtual environment
python -m venv skema_env
# On Windows:
skema_env\Scripts\activate
# On macOS/Linux:
source skema_env/bin/activate

# Install in development mode
pip install -e .
```

**Installing Git (only needed for Option 2):**
- **Windows**: `winget install --id Git.Git -e --source winget` or download from [git-scm.com](https://git-scm.com/download/win)
- **macOS**: `brew install git` or download from [git-scm.com](https://git-scm.com/download/mac)
- **Linux**: `sudo apt install git` (Ubuntu/Debian) or `sudo dnf install git` (Fedora/RHEL)

Each line explained:  
- `python -m venv skema_env`: Creates a virtual environment named `skema_env` to isolate project dependencies.  
- `skema_env\Scripts\activate` (Windows) or `source skema_env/bin/activate` (macOS/Linux): Activates the virtual environment, ensuring subsequent commands use its isolated Python and packages.  
- `pip install skema-kelp`: Installs SKeMa and all its dependencies from PyPI.

If you encounter packaging errors, make sure your pip and build tools are up to date:

```bash
pip install --upgrade pip setuptools wheel
```

#### Static files  
There are necessary **static files** that need to be downloaded. These are bathymetry and substrate files from the whole coast of British Columbia that `skema` uses when predicting kelp on a Sentinel-2 image.  

- The bathymetry file is a single TIFF raster (`Bathymetry_10m.tif`).  
- There are five substrate TIFF rasters (`NCC_substrate_20m.tif`, `SOG_substrate_20m.tif`, `WCVI_substrate_20m.tif`, `QCS_substrate_20m.tif`, `HG_substrate_20m.tif`), each covering a different region of the BC coast.  
- Place them inside:  

```text  
skema/skema/static/bathy_substrate/  
```

**⚠️ Note**: Static files (bathymetry and substrate) are only required when using the **full model** (`--model-type model_full`). If you plan to use only the **S2-only model** (`--model-type model_s2bandsandindices_only`), you can skip downloading these files.

**Sources**:  
- Canada's DEM/bathymetry model (10m resolution):  
  - Documentation: https://publications.gc.ca/collections/collection_2023/rncan-nrcan/m183-2/M183-2-8963-eng.pdf  
  - Dataset: https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/canada_west_coast_DEM_en/MapServer  

- Shallow substrate model (20m) of the Pacific Canadian coast (Haggarty et al., 2020):  
  https://osdp-psdo.canada.ca/dp/en/search/metadata/NRCAN-FGP-1-b100cf6c-7818-4748-9960-9eab2aa6a7a0  

#### GPU support  

For GPU users, install CUDA-supported PyTorch that matches your CUDA Toolkit. Check your CUDA version with:  

```bash  
nvcc --version  
```

For CUDA 12.1:  

```bash  
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121  
```

For CUDA 11.8:  

```bash  
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118  
```

Skip this step if you don't have a GPU.

---

## 🛰️ Usage

To use SKeMa after the initial installation, you must activate its virtual environment each time you start a new session (if you created one). Navigate to the directory where you created the virtual environment and activate it. If your command line prompt shows `(skema_env)`, the virtual environment is activated.

**On Windows:**
```
cd path\to\your\directory
skema_env\Scripts\activate
```

**On macOS/Linux:**
```
cd path/to/your/directory
source skema_env/bin/activate
```

This will activate the skema_env virtual environment, where SKeMa and its dependencies are installed, ensuring the tool runs correctly.

SKeMa uses Sentinel-2 satellite images, which can be downloaded from the [Copernicus Browser](https://dataspace.copernicus.eu/browser/). To access these images, you need to create a free account on the Copernicus Data Space website:
- Visit [https://dataspace.copernicus.eu/](https://dataspace.copernicus.eu/) and click "Sign Up" to create an account.
- Follow the instructions to register with your email and set a password.
- Once logged in, use the Copernicus Browser to search for and download Sentinel-2 images, which will be provided as `.zip` files.

Now, you can run SKeMa on a new Sentinel-2 image:

```bash  
skema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif  
```

- The first path (`--input-dir`) must be the full path to the `.SAFE` folder.  
  - Sentinel-2 images from the Copernicus Browser come as `.zip` files. Extract them first.  
  - Then, pass the full path to the `.SAFE` folder (e.g., `C:\...\S2C_MSIL2A_20250715T194921_N0511_R085_T09UUU_20250716T001356.SAFE`).  

- The second parameter (`--output-filename`) is the name of the output file (e.g., `output.tif`).  

### Model Types

SKeMa supports two model types:

1. **`model_full`** (default): Uses all available data including Sentinel-2 bands, bathymetry, and substrate information. This model provides the most accurate predictions but requires bathymetry and substrate static files.

2. **`model_s2bandsandindices_only`**: Uses only Sentinel-2 bands and derived spectral indices. This model does not require bathymetry or substrate files, making it suitable for areas outside British Columbia or when static files are unavailable.

To specify the model type, use the `--model-type` flag:

```bash
# Using the full model (default - includes bathymetry and substrate)
skema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif --model-type model_full

# Using S2-only model (no bathymetry/substrate required)
skema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif --model-type model_s2bandsandindices_only
```

If `--model-type` is not specified, the tool defaults to `model_full`.

### Output Files

After running, the tool generates a folder with the same name as the `.SAFE` file. Inside this folder, you'll find:

**For `model_full`:**
1. **`<SAFE_name>_B2B3B4B8.tif`**: a 10 m resolution, 4-band GeoTIFF containing Sentinel-2 bands B02 (Blue), B03 (Green), B04 (Red), and B08 (Near-Infrared).  
2. **`<SAFE_name>_B5B6B7B8A_B11B12.tif`**: a 20 m resolution, 6-band GeoTIFF containing Sentinel-2 bands B05, B06, B07, B8A, B11, and B12.  
3. **`<SAFE_name>_Bathymetry.tif`**: bathymetry data aligned and warped to the Sentinel-2 pixel grid.  
4. **`<SAFE_name>_Substrate.tif`**: substrate classification data aligned and warped to the Sentinel-2 pixel grid.  
5. **`output.tif`** (or the filename you specify): a **binary GeoTIFF**, where kelp is labeled as `1` and non-kelp as `0`.  

**For `model_s2bandsandindices_only`:**
1. **`<SAFE_name>_B2B3B4B8.tif`**: a 10 m resolution, 4-band GeoTIFF containing Sentinel-2 bands B02 (Blue), B03 (Green), B04 (Red), and B08 (Near-Infrared).  
2. **`<SAFE_name>_B5B6B7B8A_B11B12.tif`**: a 20 m resolution, 6-band GeoTIFF containing Sentinel-2 bands B05, B06, B07, B8A, B11, and B12.  
3. **`output.tif`** (or the filename you specify): a **binary GeoTIFF**, where kelp is labeled as `1` and non-kelp as `0`.

---

## ⚙️ Project Structure

```text  
skema/  
├── skema/  
│   ├── cli.py  
│   ├── lib.py  
│   ├── __init__.py  
│   │  
│   └── static/  
│       ├── __init__.py  
│       │  
│       └── bathy_substrate/  
│           ├── __init__.py  
│           ├── Bathymetry_10m.tif  
│           ├── NCC_substrate_20m.tif  
│           ├── SOG_substrate_20m.tif  
│           ├── WCVI_substrate_20m.tif  
│           ├── QCS_substrate_20m.tif  
│           └── HG_substrate_20m.tif  
├── pyproject.toml  
├── setup.py  
├── requirements.txt  
├── README.md  
```

---

## 📜 License
- **Code**: MIT License (see LICENSE file)
- **Model**: The trained model is licensed under **CC-BY-4.0** — please cite the DOI when using it.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "skema-kelp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "kelp, sentinel-2, semantic-segmentation, remote-sensing, satellite-imagery, deep-learning, pytorch",
    "author": null,
    "author_email": "Mohsen Ghanbari <mohsenghanbari@uvic.ca>",
    "download_url": "https://files.pythonhosted.org/packages/8f/93/a82288bd343fc45121cf271d3235a133639f06929baa91336b894b936ee1/skema_kelp-0.1.1.tar.gz",
    "platform": null,
    "description": "# SKeMa\r\n[![DOI](https://img.shields.io/badge/DOI-10.57967%2Fhf%2F6790-blue)](https://doi.org/10.57967/hf/6790)\r\n[![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-SKeMa-yellow)](https://huggingface.co/m5ghanba/SKeMa)\r\n[![PyPI](https://img.shields.io/pypi/v/skema-kelp)](https://pypi.org/project/skema-kelp/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n[![Model License: CC BY 4.0](https://img.shields.io/badge/Model%20License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)\r\n\r\n**Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery**\r\n\r\n`skema` is a Python tool for classifying kelp in Sentinel-2 satellite images using a deep learning segmentation model (PyTorch). It provides a command-line interface (CLI) for easy, reproducible inference. To run the tool you would need to download Sentinel-2 images from the Copernicus Browser. More detailed instruction on how to download these images can be found in Section Usage. The following instructions are provided for anyone with no knowledge of what a command line is, no knowledge of Python or virtual environments, etc. Just follow along step by step.\r\n\r\n**Model available on Hugging Face**: [m5ghanba/SKeMa](https://huggingface.co/m5ghanba/SKeMa)  \r\n**DOI**: [10.57967/hf/6790](https://doi.org/10.57967/hf/6790)\r\n\r\n---\r\n\r\n## \u26a1 Quick Start (Experienced Users)\r\n```bash\r\npip install skema-kelp\r\n\r\n# Download static files (for model_full only) from sources listed below\r\n# Download Sentinel-2 imagery from https://dataspace.copernicus.eu/browser/\r\n\r\nskema --input-dir path/to/S2_scene.SAFE --output-filename output.tif\r\n\r\n# For help and all options\r\nskema --help\r\n```\r\n\r\n**For detailed installation instructions (beginner-friendly), see [Installation](#-installation) below.**\r\n\r\n---\r\n\r\n## Citation\r\n\r\nIf you use **SKeMa** in your research or work, please cite:\r\n\r\n```bibtex\r\n@software{skema_2025,\r\n  author       = {Mohsen Ghanbari et al.},\r\n  title        = {SKeMa: Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery},\r\n  year         = 2025,\r\n  publisher    = {Hugging Face},\r\n  doi          = {10.57967/hf/6790},\r\n  url          = {https://huggingface.co/m5ghanba/SKeMa}\r\n}\r\n```\r\n\r\n**Plain text**:  \r\nGhanbari, M., et al. (2025). *SKeMa: Satellite-based Kelp Mapping using Semantic Segmentation on Sentinel-2 imagery*. Hugging Face. https://doi.org/10.57967/hf/6790\r\n\r\n---\r\n\r\n## \ud83d\ude80 Installation\r\n\r\nBefore you can set up SKeMa, you'll need **Python** (version 3.8 or higher) installed on your computer. Python is a free tool, and no accounts or sign-ups are required to install it. We'll install it using your terminal (command line) where possible for simplicity. If you're on Windows, ensure you're using **PowerShell** or **Command Prompt** as Administrator (right-click and select \"Run as administrator\") for some steps.\r\n\r\n### Step 1: Install Python\r\n\r\n#### On Windows\r\n1. **Check if Winget is available** (it's built into Windows 10 version 2009 or later, or Windows 11, and most modern systems have it):\r\n   - Open PowerShell or Command Prompt.\r\n   - Type `winget --version` and press Enter.\r\n   - If it shows a version number (e.g., \"v1.8.0\"), proceed. If not (error like \"winget is not recognized\"), download the App Installer from the Microsoft Store (search for \"App Installer\") or update Windows via Settings > Update & Security > Windows Update.\r\n\r\n2. **Install Python 3.12** (the latest stable version as of October 2025; this meets the >=3.8 requirement):\r\n   - In your terminal, run:\r\n     ```\r\n     winget install -e --id Python.Python.3.12\r\n     ```\r\n   - This downloads and installs Python automatically. It may take a few minutes.\r\n   - **Important**: During installation (if prompted), ensure \"Add Python to PATH\" is selected (it usually is by default with winget).\r\n   - Restart your terminal after installation.\r\n   - Verify: Run `python --version`. It should output something like \"Python 3.12.7\". If not, close and reopen the terminal, or manually add Python to PATH (search online for \"add Python to PATH Windows\").\r\n\r\n   *Alternative if winget fails*: Download the installer from [python.org](https://www.python.org/downloads/windows/) using your browser, run it, and follow the GUI prompts (make sure to check \"Add Python to PATH\"). Then verify as above.\r\n\r\n#### On macOS\r\n1. **Install Homebrew** (a package manager for CLI installations, if you don't have it):\r\n   - Open Terminal (search for it in Spotlight with Cmd+Space).\r\n   - Run:\r\n     ```\r\n     /bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\r\n     ```\r\n   - Follow any on-screen prompts (it may ask for your password; this is normal). No account needed.\r\n   - After installation, run the commands it suggests to add Homebrew to your PATH (e.g., `echo 'eval \"$(/opt/homebrew/bin/brew shellenv)\"' >> ~/.zprofile` and then `eval \"$(/opt/homebrew/bin/brew shellenv)\"`).\r\n   - Verify: Run `brew --version`. It should show a version like \"4.3.0\".\r\n\r\n2. **Install Python 3.12**:\r\n   - Run:\r\n     ```\r\n     brew install python@3.12\r\n     ```\r\n   - This installs Python and adds it to PATH.\r\n   - Verify: Run `python3 --version` (note: use `python3` on macOS). It should output \"Python 3.12.7\".\r\n\r\n   *Alternative*: Download the official installer from [python.org](https://www.python.org/downloads/macos/) using your browser, run it, and follow GUI steps.\r\n\r\n#### On Linux (e.g., Ubuntu/Debian; adjust for other distros like Fedora)\r\n1. **Update your package list**:\r\n   - Open your terminal.\r\n   - Run:\r\n     ```\r\n     sudo apt update\r\n     ```\r\n   - Enter your password when prompted (sudo is for admin privileges; no account needed beyond your user login).\r\n\r\n2. **Install Python 3.12**:\r\n   - Run:\r\n     ```\r\n     sudo apt install python3.12 python3.12-venv python3-pip\r\n     ```\r\n   - This installs Python, the venv module, and pip.\r\n   - Verify: Run `python3 --version`. It should output \"Python 3.12.x\".\r\n   - *For Fedora/RHEL*: Use `sudo dnf install python3.12` instead.\r\n\r\n   *Note*: If your distro's repositories don't have Python 3.12, add a PPA (e.g., for Ubuntu: `sudo add-apt-repository ppa:deadsnakes/ppa` then update and install).\r\n\r\nOnce Python is installed and verified, proceed to the next section. If you encounter errors (e.g., \"command not found\"), search online for the exact error message + your OS.\r\n\r\n### Step 2: Install SKeMa\r\n\r\nOpen your **terminal**:  \r\n- On **Windows**, you can use Command Prompt or PowerShell.  \r\n- On **macOS**, open the Terminal app.  \r\n- On **Linux**, open your terminal emulator of choice.  \r\n\r\nWhen you open a terminal, you start inside a **directory (folder)**. You can move to another directory with the command `cd`. For example:  \r\n\r\n```  \r\ncd C:\\Users\\YourName\\Documents  \r\n```  \r\n\r\nOn macOS/Linux:  \r\n\r\n```  \r\ncd /Users/yourname/Documents  \r\n```  \r\n\r\n\ud83d\udc49 The easiest way to navigate is to open your file explorer, go to the folder you want, then copy its full path and paste it after `cd` on the command line. For more details, look up \"basic terminal navigation\" online.  \r\n\r\nNow, navigate to a directory where you want to work with SKeMa, then run:\r\n\r\n#### Option 1: Install with pip (Recommended)\r\n\r\n```bash\r\n# Create a virtual environment (optional but recommended)\r\npython -m venv skema_env\r\n\r\n# Activate the virtual environment\r\n# On Windows:\r\nskema_env\\Scripts\\activate\r\n# On macOS/Linux:\r\nsource skema_env/bin/activate\r\n\r\n# Install SKeMa\r\npip install skema-kelp\r\n```\r\n\r\n#### Option 2: Install from source (for developers)\r\n\r\nIf you want to modify the code or contribute to development:\r\n\r\n```bash\r\n# Install Git first (see system-specific instructions below)\r\n# Then clone the repository\r\ngit clone https://github.com/m5ghanba/skema.git\r\ncd skema\r\n\r\n# Create and activate virtual environment\r\npython -m venv skema_env\r\n# On Windows:\r\nskema_env\\Scripts\\activate\r\n# On macOS/Linux:\r\nsource skema_env/bin/activate\r\n\r\n# Install in development mode\r\npip install -e .\r\n```\r\n\r\n**Installing Git (only needed for Option 2):**\r\n- **Windows**: `winget install --id Git.Git -e --source winget` or download from [git-scm.com](https://git-scm.com/download/win)\r\n- **macOS**: `brew install git` or download from [git-scm.com](https://git-scm.com/download/mac)\r\n- **Linux**: `sudo apt install git` (Ubuntu/Debian) or `sudo dnf install git` (Fedora/RHEL)\r\n\r\nEach line explained:  \r\n- `python -m venv skema_env`: Creates a virtual environment named `skema_env` to isolate project dependencies.  \r\n- `skema_env\\Scripts\\activate` (Windows) or `source skema_env/bin/activate` (macOS/Linux): Activates the virtual environment, ensuring subsequent commands use its isolated Python and packages.  \r\n- `pip install skema-kelp`: Installs SKeMa and all its dependencies from PyPI.\r\n\r\nIf you encounter packaging errors, make sure your pip and build tools are up to date:\r\n\r\n```bash\r\npip install --upgrade pip setuptools wheel\r\n```\r\n\r\n#### Static files  \r\nThere are necessary **static files** that need to be downloaded. These are bathymetry and substrate files from the whole coast of British Columbia that `skema` uses when predicting kelp on a Sentinel-2 image.  \r\n\r\n- The bathymetry file is a single TIFF raster (`Bathymetry_10m.tif`).  \r\n- There are five substrate TIFF rasters (`NCC_substrate_20m.tif`, `SOG_substrate_20m.tif`, `WCVI_substrate_20m.tif`, `QCS_substrate_20m.tif`, `HG_substrate_20m.tif`), each covering a different region of the BC coast.  \r\n- Place them inside:  \r\n\r\n```text  \r\nskema/skema/static/bathy_substrate/  \r\n```\r\n\r\n**\u26a0\ufe0f Note**: Static files (bathymetry and substrate) are only required when using the **full model** (`--model-type model_full`). If you plan to use only the **S2-only model** (`--model-type model_s2bandsandindices_only`), you can skip downloading these files.\r\n\r\n**Sources**:  \r\n- Canada's DEM/bathymetry model (10m resolution):  \r\n  - Documentation: https://publications.gc.ca/collections/collection_2023/rncan-nrcan/m183-2/M183-2-8963-eng.pdf  \r\n  - Dataset: https://maps-cartes.services.geo.ca/server_serveur/rest/services/NRCan/canada_west_coast_DEM_en/MapServer  \r\n\r\n- Shallow substrate model (20m) of the Pacific Canadian coast (Haggarty et al., 2020):  \r\n  https://osdp-psdo.canada.ca/dp/en/search/metadata/NRCAN-FGP-1-b100cf6c-7818-4748-9960-9eab2aa6a7a0  \r\n\r\n#### GPU support  \r\n\r\nFor GPU users, install CUDA-supported PyTorch that matches your CUDA Toolkit. Check your CUDA version with:  \r\n\r\n```bash  \r\nnvcc --version  \r\n```\r\n\r\nFor CUDA 12.1:  \r\n\r\n```bash  \r\npip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121  \r\n```\r\n\r\nFor CUDA 11.8:  \r\n\r\n```bash  \r\npip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118  \r\n```\r\n\r\nSkip this step if you don't have a GPU.\r\n\r\n---\r\n\r\n## \ud83d\udef0\ufe0f Usage\r\n\r\nTo use SKeMa after the initial installation, you must activate its virtual environment each time you start a new session (if you created one). Navigate to the directory where you created the virtual environment and activate it. If your command line prompt shows `(skema_env)`, the virtual environment is activated.\r\n\r\n**On Windows:**\r\n```\r\ncd path\\to\\your\\directory\r\nskema_env\\Scripts\\activate\r\n```\r\n\r\n**On macOS/Linux:**\r\n```\r\ncd path/to/your/directory\r\nsource skema_env/bin/activate\r\n```\r\n\r\nThis will activate the skema_env virtual environment, where SKeMa and its dependencies are installed, ensuring the tool runs correctly.\r\n\r\nSKeMa uses Sentinel-2 satellite images, which can be downloaded from the [Copernicus Browser](https://dataspace.copernicus.eu/browser/). To access these images, you need to create a free account on the Copernicus Data Space website:\r\n- Visit [https://dataspace.copernicus.eu/](https://dataspace.copernicus.eu/) and click \"Sign Up\" to create an account.\r\n- Follow the instructions to register with your email and set a password.\r\n- Once logged in, use the Copernicus Browser to search for and download Sentinel-2 images, which will be provided as `.zip` files.\r\n\r\nNow, you can run SKeMa on a new Sentinel-2 image:\r\n\r\n```bash  \r\nskema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif  \r\n```\r\n\r\n- The first path (`--input-dir`) must be the full path to the `.SAFE` folder.  \r\n  - Sentinel-2 images from the Copernicus Browser come as `.zip` files. Extract them first.  \r\n  - Then, pass the full path to the `.SAFE` folder (e.g., `C:\\...\\S2C_MSIL2A_20250715T194921_N0511_R085_T09UUU_20250716T001356.SAFE`).  \r\n\r\n- The second parameter (`--output-filename`) is the name of the output file (e.g., `output.tif`).  \r\n\r\n### Model Types\r\n\r\nSKeMa supports two model types:\r\n\r\n1. **`model_full`** (default): Uses all available data including Sentinel-2 bands, bathymetry, and substrate information. This model provides the most accurate predictions but requires bathymetry and substrate static files.\r\n\r\n2. **`model_s2bandsandindices_only`**: Uses only Sentinel-2 bands and derived spectral indices. This model does not require bathymetry or substrate files, making it suitable for areas outside British Columbia or when static files are unavailable.\r\n\r\nTo specify the model type, use the `--model-type` flag:\r\n\r\n```bash\r\n# Using the full model (default - includes bathymetry and substrate)\r\nskema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif --model-type model_full\r\n\r\n# Using S2-only model (no bathymetry/substrate required)\r\nskema --input-dir path/to/sentinel2/safe/folder --output-filename output.tif --model-type model_s2bandsandindices_only\r\n```\r\n\r\nIf `--model-type` is not specified, the tool defaults to `model_full`.\r\n\r\n### Output Files\r\n\r\nAfter running, the tool generates a folder with the same name as the `.SAFE` file. Inside this folder, you'll find:\r\n\r\n**For `model_full`:**\r\n1. **`<SAFE_name>_B2B3B4B8.tif`**: a 10 m resolution, 4-band GeoTIFF containing Sentinel-2 bands B02 (Blue), B03 (Green), B04 (Red), and B08 (Near-Infrared).  \r\n2. **`<SAFE_name>_B5B6B7B8A_B11B12.tif`**: a 20 m resolution, 6-band GeoTIFF containing Sentinel-2 bands B05, B06, B07, B8A, B11, and B12.  \r\n3. **`<SAFE_name>_Bathymetry.tif`**: bathymetry data aligned and warped to the Sentinel-2 pixel grid.  \r\n4. **`<SAFE_name>_Substrate.tif`**: substrate classification data aligned and warped to the Sentinel-2 pixel grid.  \r\n5. **`output.tif`** (or the filename you specify): a **binary GeoTIFF**, where kelp is labeled as `1` and non-kelp as `0`.  \r\n\r\n**For `model_s2bandsandindices_only`:**\r\n1. **`<SAFE_name>_B2B3B4B8.tif`**: a 10 m resolution, 4-band GeoTIFF containing Sentinel-2 bands B02 (Blue), B03 (Green), B04 (Red), and B08 (Near-Infrared).  \r\n2. **`<SAFE_name>_B5B6B7B8A_B11B12.tif`**: a 20 m resolution, 6-band GeoTIFF containing Sentinel-2 bands B05, B06, B07, B8A, B11, and B12.  \r\n3. **`output.tif`** (or the filename you specify): a **binary GeoTIFF**, where kelp is labeled as `1` and non-kelp as `0`.\r\n\r\n---\r\n\r\n## \u2699\ufe0f Project Structure\r\n\r\n```text  \r\nskema/  \r\n\u251c\u2500\u2500 skema/  \r\n\u2502   \u251c\u2500\u2500 cli.py  \r\n\u2502   \u251c\u2500\u2500 lib.py  \r\n\u2502   \u251c\u2500\u2500 __init__.py  \r\n\u2502   \u2502  \r\n\u2502   \u2514\u2500\u2500 static/  \r\n\u2502       \u251c\u2500\u2500 __init__.py  \r\n\u2502       \u2502  \r\n\u2502       \u2514\u2500\u2500 bathy_substrate/  \r\n\u2502           \u251c\u2500\u2500 __init__.py  \r\n\u2502           \u251c\u2500\u2500 Bathymetry_10m.tif  \r\n\u2502           \u251c\u2500\u2500 NCC_substrate_20m.tif  \r\n\u2502           \u251c\u2500\u2500 SOG_substrate_20m.tif  \r\n\u2502           \u251c\u2500\u2500 WCVI_substrate_20m.tif  \r\n\u2502           \u251c\u2500\u2500 QCS_substrate_20m.tif  \r\n\u2502           \u2514\u2500\u2500 HG_substrate_20m.tif  \r\n\u251c\u2500\u2500 pyproject.toml  \r\n\u251c\u2500\u2500 setup.py  \r\n\u251c\u2500\u2500 requirements.txt  \r\n\u251c\u2500\u2500 README.md  \r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcdc License\r\n- **Code**: MIT License (see LICENSE file)\r\n- **Model**: The trained model is licensed under **CC-BY-4.0** \u2014 please cite the DOI when using it.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Satellite-based kelp classification from Sentinel-2 using semantic segmentation",
    "version": "0.1.1",
    "project_urls": {
        "DOI": "https://doi.org/10.57967/hf/6790",
        "Documentation": "https://github.com/m5ghanba/skema#readme",
        "Homepage": "https://github.com/m5ghanba/skema",
        "Hugging Face": "https://huggingface.co/m5ghanba/SKeMa",
        "Issues": "https://github.com/m5ghanba/skema/issues",
        "Repository": "https://github.com/m5ghanba/skema"
    },
    "split_keywords": [
        "kelp",
        " sentinel-2",
        " semantic-segmentation",
        " remote-sensing",
        " satellite-imagery",
        " deep-learning",
        " pytorch"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d2335cf56cf67e3b0154e7645de9cec4dab7e053db06f42e86b95ced19c71d93",
                "md5": "518dc6d97178cfa917320fb9525dbb0c",
                "sha256": "439464ce47b9e780a7c210b69bde6f5b92275aa2252fd9349a59058f2e85250e"
            },
            "downloads": -1,
            "filename": "skema_kelp-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "518dc6d97178cfa917320fb9525dbb0c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.8",
            "size": 25161,
            "upload_time": "2025-10-31T00:37:39",
            "upload_time_iso_8601": "2025-10-31T00:37:39.353132Z",
            "url": "https://files.pythonhosted.org/packages/d2/33/5cf56cf67e3b0154e7645de9cec4dab7e053db06f42e86b95ced19c71d93/skema_kelp-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8f93a82288bd343fc45121cf271d3235a133639f06929baa91336b894b936ee1",
                "md5": "7f6b44fdc027473b01c3b27fb21458dc",
                "sha256": "8f7eae6e645f6b04635f2a83c800764b2159c0e50b0f6f1e0270947c442b1ffa"
            },
            "downloads": -1,
            "filename": "skema_kelp-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7f6b44fdc027473b01c3b27fb21458dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 30699,
            "upload_time": "2025-10-31T00:37:40",
            "upload_time_iso_8601": "2025-10-31T00:37:40.572387Z",
            "url": "https://files.pythonhosted.org/packages/8f/93/a82288bd343fc45121cf271d3235a133639f06929baa91336b894b936ee1/skema_kelp-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-31 00:37:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "m5ghanba",
    "github_project": "skema#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "torch",
            "specs": [
                [
                    "==",
                    "2.7.0"
                ]
            ]
        },
        {
            "name": "torchvision",
            "specs": [
                [
                    "==",
                    "0.22.0"
                ]
            ]
        },
        {
            "name": "pytorch-lightning",
            "specs": [
                [
                    "==",
                    "2.5.1.post0"
                ]
            ]
        },
        {
            "name": "segmentation-models-pytorch",
            "specs": [
                [
                    "==",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "torchmetrics",
            "specs": [
                [
                    "==",
                    "1.7.1"
                ]
            ]
        },
        {
            "name": "albumentations",
            "specs": [
                [
                    "==",
                    "1.4.24"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.26.4"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    "==",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    "==",
                    "1.3.2"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    "==",
                    "1.11.4"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    "==",
                    "3.7.5"
                ]
            ]
        },
        {
            "name": "tifffile",
            "specs": [
                [
                    "==",
                    "2023.4.12"
                ]
            ]
        },
        {
            "name": "rasterio",
            "specs": [
                [
                    "==",
                    "1.4.3"
                ]
            ]
        },
        {
            "name": "cppy",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "kiwisolver",
            "specs": [
                [
                    "==",
                    "1.4.5"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    "==",
                    "4.67.1"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.2.0"
                ]
            ]
        }
    ],
    "lcname": "skema-kelp"
}
        
Elapsed time: 2.70538s