Skip to content

Commit

Permalink
update ignore file and README
Browse files Browse the repository at this point in the history
  • Loading branch information
coolzhao committed Jun 14, 2023
1 parent 28f5490 commit 7cd1c72
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 477 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ __pycache__/geo_sam_tool.cpython-39.pyc
__pycache__/sam_ext.cpython-39.pyc
__pycache__/__init__.cpython-39.pyc
__pycache__/torchgeo_sam.cpython-39.pyc
features/**/*.csv
.DS_Store
85 changes: 84 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,85 @@
# Geo-SAM
Using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.

By Joey and Fancy from CryoLab, ESSC, CUHK.

## Introduction

Geo SAM is a tool aims to help people segment, delineate or label landforms with large-size geo-spatial raster images.
Segment Anything Model (SAM) is foundation AI vision model with super power, but the model size is large and using it to process images can take a long time, and a modern GPU is usually needed.
With the pre-generated image features using Vision Transformer image encoder, the interactive segmentation process can be run in real-time on a laptop without dedicated GPU.

## Installation

### Install QGIS

You are recommended to install the latest version of QGIS, since the plugin has only been tested on the versions later than QGIS 3.30, at least ver. 2.28 is recommended.

## Install Library Dependencies

### For Windows Users

![OsGeo4WShell](./assets/OsGeo4WShell.png)

<!-- <p align="center">
<img src="./assets/OsGeo4WShell.png" width="100" title="OsGeo4WShell"> -->
<!-- <img src="./assets/OsGeo4WShell.png" width="100" alt="OsGeo4WShell"> -->
<!-- </p> -->

Open the `OSGeo4W Shell` application, which is dedicated shell for the QGIS. Then run the following command to install the libraries.

```bash
pip3 install torch==1.13.1 torchvision==0.14.1
pip3 install torchgeo
pip3 install segment-anything
pip3 install rasterio==1.3.7
```

### For Mac or Linux Users

Open your own terminal application, and change the directory to the QGIS Python environment.

```bash
# Mac
cd /<qgispath>/Contents/Resources/python
# Linux
cd /<qgispath>/share/qgis/python
```

Then install the libraries.

```bash
./pip3 install torch==1.13.1 torchvision==0.14.1
./pip3 install torchgeo
./pip3 install segment-anything
./pip3 install rasterio==1.3.7
```

## Install the GeoSAM Plugin

Download the plugin zip file, unzip and put the contents in the plugin folder, then restart QGIS.

### How to Find the QGIS Plugin folder

From the `Settings` Menu, `User Profiles`, select `Open active profile folder.` You'll be taken straight to the profile directory in Explorer or Finder. Under the profile folder you may find a `python` folder, the plugins folder should be right inside the python folder. Open the `plugins` folder, then put the entire `Geo-SAM` folder in it (avoid nested folder after unzipping), then restart QGIS.

Below are some general paths of different systems for your reference.

```bash
# Windows
%APPDATA%\QGIS\QGIS3\profiles\default\python\plugins
# Mac
~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins
# Linux
~/.local/share/QGIS/QGIS3/profiles/default/python/plugins
```

### Activate Geo SAM Plugin

After restarting QGIS, you may go to the `Plugins` menu, select `Manage and Install Plugins`, under `Installed`, you may find the `Geo SAM` plugin, check it to activate the plugin.

## Tips for Using GeoSAM Tool

- Deal with only **One Subject** each time
- Use **Background Points** to exclude unwanted parts
- Use **Bounding Box (BBox)** to limit the segment polygon boundary
- The **BBox** should cover the entire subject
Binary file added assets/OsGeo4WShell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading

0 comments on commit 7cd1c72

Please sign in to comment.