|
10 | 10 | "[](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/segment-geospatial&urlpath=lab/tree/segment-geospatial/docs/examples/fast_sam.ipynb&branch=main)\n", |
11 | 11 | "[](https://colab.research.google.com/github/opengeos/segment-geospatial/blob/main/docs/examples/fast_sam.ipynb)\n", |
12 | 12 | "\n", |
| 13 | + "FastSAM: https://github.com/CASIA-IVA-Lab/FastSAM\n", |
| 14 | + "\n", |
13 | 15 | "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. " |
14 | 16 | ] |
15 | 17 | }, |
|
143 | 145 | "sam = SamGeo(model=\"FastSAM-x.pt\")" |
144 | 146 | ] |
145 | 147 | }, |
| 148 | + { |
| 149 | + "cell_type": "markdown", |
| 150 | + "metadata": {}, |
| 151 | + "source": [ |
| 152 | + "Set the image." |
| 153 | + ] |
| 154 | + }, |
146 | 155 | { |
147 | 156 | "cell_type": "code", |
148 | 157 | "execution_count": null, |
|
152 | 161 | "sam.set_image(\"Image.tif\")" |
153 | 162 | ] |
154 | 163 | }, |
| 164 | + { |
| 165 | + "cell_type": "markdown", |
| 166 | + "metadata": {}, |
| 167 | + "source": [ |
| 168 | + "Segment the image with `everything_prompt`. You can also try `point_prompt`, `box_prompt`, or `text_prompt`." |
| 169 | + ] |
| 170 | + }, |
155 | 171 | { |
156 | 172 | "cell_type": "code", |
157 | 173 | "execution_count": null, |
|
161 | 177 | "sam.everything_prompt(output=\"mask.tif\")" |
162 | 178 | ] |
163 | 179 | }, |
| 180 | + { |
| 181 | + "cell_type": "markdown", |
| 182 | + "metadata": {}, |
| 183 | + "source": [ |
| 184 | + "Show the annotated image." |
| 185 | + ] |
| 186 | + }, |
| 187 | + { |
| 188 | + "cell_type": "code", |
| 189 | + "execution_count": null, |
| 190 | + "metadata": {}, |
| 191 | + "outputs": [], |
| 192 | + "source": [ |
| 193 | + "sam.show_anns(\"mask.png\")" |
| 194 | + ] |
| 195 | + }, |
| 196 | + { |
| 197 | + "cell_type": "markdown", |
| 198 | + "metadata": {}, |
| 199 | + "source": [ |
| 200 | + "" |
| 201 | + ] |
| 202 | + }, |
| 203 | + { |
| 204 | + "cell_type": "markdown", |
| 205 | + "metadata": {}, |
| 206 | + "source": [ |
| 207 | + "Convert the segmentation results from GeoTIFF to vector." |
| 208 | + ] |
| 209 | + }, |
164 | 210 | { |
165 | 211 | "cell_type": "code", |
166 | 212 | "execution_count": null, |
|
170 | 216 | "sam.raster_to_vector(\"mask.tif\", \"mask.geojson\")" |
171 | 217 | ] |
172 | 218 | }, |
| 219 | + { |
| 220 | + "cell_type": "markdown", |
| 221 | + "metadata": {}, |
| 222 | + "source": [ |
| 223 | + "Show the segmentation results on the map." |
| 224 | + ] |
| 225 | + }, |
173 | 226 | { |
174 | 227 | "cell_type": "code", |
175 | 228 | "execution_count": null, |
|
0 commit comments