This project provides a robust, multi-user interactive tool for generating accurate segmentation masks of Retrogressive Thaw Slumps (RTS) from satellite imagery. The tool is designed to run in a Google Colab environment, leveraging a Segment Anything Model (SAM) with few-click prompting to accelerate the creation of high-quality training data for deep learning models.
The primary goal is to streamline the process of refining existing, misaligned polygon labels by allowing a user to interactively generate new, accurate polygons on a stable basemap.
- Interactive Segmentation: Uses a pre-trained SAM model to generate segmentation masks from simple positive and negative point prompts.
- UID-Centric Workflow: The fundamental unit of work is a unique RTS feature (identified by a UID), allowing for the contextual display of all historical polygons for that feature.
- Multi-User Support: A central
manifest.csv
file tracks the labeling progress of each UID, preventing duplicate work and allowing multiple labelers to work in parallel. - Direct GCS Integration: Efficiently loads and processes Planet satellite imagery directly from Google Cloud Storage.
- Designed for Colab: The entire workflow is encapsulated in a single Google Colab notebook, providing easy access to free GPU resources for model inference.
This is the primary method for using the tool. No local installation is required.
-
Open the Notebook in Colab
- Click the following link to open the main application notebook directly in Google Colab: Open in Colab
- If the link doesn't work, go to
File > Open notebook
in Colab, select the "GitHub" tab, enter the repository URL (https://github.com/whrc/interactive-sam2
), and opennotebooks/interactive_label_sam2.ipynb
.
-
Run the Setup Cells
- Execute the first few cells in the notebook (under the "Environment Setup & Authentication" section).
- These cells will automatically install the required libraries and clone the project code into the Colab environment.
-
Authenticate Your Google Account
- You will be prompted to authenticate with your Google account. This is required to grant the notebook secure access to the project's Google Cloud Storage bucket where the images are stored.
- Follow the on-screen instructions to log in and grant permission.
-
Start Labeling
- Once the setup and authentication cells have completed successfully, you can run the final cells to launch the interactive user interface and begin labeling.
This setup is only for developers who want to modify the Python source code in the src/
directory. If you only need to use the tool, please follow the Colab instructions above.
- Git: Install Git.
- Git LFS: Install Git Large File Storage. This is required to handle the large GeoJSON datasets.
- Anaconda: Install Anaconda or Miniconda (Miniconda is recommended).
-
Clone the Repository Open an Anaconda Prompt or terminal and clone the project.
git clone [https://github.com/whrc/interactive-sam2.git](https://github.com/whrc/interactive-sam2.git) cd interactive-sam2
-
Download Large Files Pull the large data files tracked by Git LFS.
git lfs pull
-
Create and Activate the Conda Environment This command reads the
environment.yml
file and creates a new, isolated environment namedinteractive-sam2
with all the necessary libraries.conda env create -f environment.yml conda activate interactive-sam2
You can now edit the files in src/
and test your changes using the scripts in the tests/
directory.
Contributions to this project are welcome. Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix (
git checkout -b feature/your-feature-name
). - Make your changes and commit them with clear, descriptive messages.
- Push your changes to your fork (
git push origin feature/your-feature-name
). - Create a new Pull Request against the main repository.
This project is licensed under the MIT License - see the LICENSE
file for details.