SamGIS QGIS Plugin - SAM2 Instance Segmentation on Your PC
This QGIS plugin brings Meta's Segment Anything Model 2 (SAM2) into QGIS, enabling instance segmentation directly on your PC and fully offline. No cloud APIs, no dedicated GPU — models run on-device via ONNX Runtime.
The plugin is part of the SamGIS ecosystem. While the web demo relies on a FastAPI backend using remote tile providers (e.g. OpenStreetMap), SamGIS for QGIS works entirely offline with any georeferenced image in a QGIS project.
Models are downloaded once from Hugging Face and stored locally in ~/.samgis/models/.
Screenshots
| Select layers and prompts | Instance segmentation result |
|---|---|
How it works
- Install the QGIS plugin =) (the Python dependencies are handled under the hood by the plugin itself)
- Load a georeferenced raster layer in QGIS
- Create vector layers with point prompts (foreground/background) or rectangles (foreground only)
- Select the raster layer and the vector layer(s) from the SamGIS modal dialog
- If no SAM2 model is present, the plugin will prompt you to choose and download one (e.g. "SAM 2.1 Tiny uint8" ~32 MB for a quick start)
- The pipeline then
- converts geographic (or projected, depending on the CRS) coordinates to pixel coordinates
- runs the actual inference using the selected model
- returns the segmentation mask converted to a polygon vector layer with CRS "EPSG:4326"
Key features
- Fully offline — models are downloaded once and stored locally
- 8 model variants — 4 sizes (Tiny, Small, Base+, Large) x 2 precisions (uint8, fp32)
- Point prompts — foreground (label=1) and background (label=0) points
- Rectangle prompts — bounding box via polygon vector layer
- Background inference — UI stays responsive during model execution
- Multi-band handling — supports grayscale, RGB, and multi-band rasters (1-3 bands)
- EPSG:4326 output — results are added as polygon vector layers
- Model management — download and selection via a dedicated settings dialog
Resources
- Source code and full documentation: trincadev/samgis-qgis-plugin
- Related: SamGIS web demo
- Requires QGIS 3.40+ LTR

