Segmenting remote sensing imagery with FastSAM¶
FastSAM: https://github.com/CASIA-IVA-Lab/FastSAM
Make sure you use GPU runtime for this notebook. For Google Colab, go to Runtime -> Change runtime type and select GPU as the hardware accelerator.
Install dependencies¶
Uncomment and run the following cell to install the required dependencies.
1 | |
1 2 | |
Create an interactive map¶
1 2 3 | |
Download a sample image¶
Pan and zoom the map to select the area of interest. Use the draw tools to draw a polygon or rectangle on the map
1 2 3 | |
1 2 | |
You can also use your own image. Uncomment and run the following cell to use your own image.
1 | |
Display the downloaded image on the map.
1 2 3 | |
Initialize SamGeo class¶
The initialization of the SamGeo class might take a few minutes. The initialization downloads the model weights and sets up the model for inference.
1 2 3 | |
Set the image.
1 | |
Segment the image with everything_prompt. You can also try point_prompt, box_prompt, or text_prompt.
1 | |
Show the annotated image.
1 | |

Convert the segmentation results from GeoTIFF to vector.
1 | |
Show the segmentation results on the map.
1 2 3 | |
