|
9 | 9 | "source": [
|
10 | 10 | "[](https://colab.research.google.com/github/opengeos/segment-geospatial/blob/main/docs/workshops/IPPN_2024.ipynb)\n",
|
11 | 11 | "\n",
|
12 |
| - "**Open Source Pipeline for UAS and satellite based High Throughput Phenotyping Applications**\n", |
| 12 | + "**Open Source Pipeline for UAS and satellite based High Throughput Phenotyping Applications - Part 1**\n", |
13 | 13 | "\n",
|
14 |
| - "This notebook is designed for workshop presented at the [International Plant Phenotyping Network (IPPN)](https://www.plant-phenotyping.org/ipps8) conference on October 7, 2024. Click the **Open in Colab** button above to run this notebook interactively in the cloud.\n", |
| 14 | + "This notebook is designed for workshop presented at the [International Plant Phenotyping Network (IPPN)](https://www.plant-phenotyping.org/ipps8) conference on October 7, 2024. Click the **Open in Colab** button above to run this notebook interactively in the cloud. For Part 2 of the workshop, please click [here](https://geemap.org/workshops/IPPN_2024/).\n", |
15 | 15 | "\n",
|
16 | 16 | "- Registration: <https://www.plant-phenotyping.org/index.php?index=935>\n",
|
17 | 17 | "- Notebook: <https://samgeo.gishub.org/workshops/IPPN_2024>\n",
|
|
946 | 946 | "metadata": {},
|
947 | 947 | "outputs": [],
|
948 | 948 | "source": [
|
949 |
| - "from samgeo import SamGeo2" |
| 949 | + "from samgeo import SamGeo, SamGeo2" |
950 | 950 | ]
|
951 | 951 | },
|
952 | 952 | {
|
|
1212 | 1212 | " label2=\"Image Segmentation\",\n",
|
1213 | 1213 | ")"
|
1214 | 1214 | ]
|
| 1215 | + }, |
| 1216 | + { |
| 1217 | + "cell_type": "markdown", |
| 1218 | + "id": "105", |
| 1219 | + "metadata": {}, |
| 1220 | + "source": [ |
| 1221 | + "### Using box prompts" |
| 1222 | + ] |
| 1223 | + }, |
| 1224 | + { |
| 1225 | + "cell_type": "code", |
| 1226 | + "execution_count": null, |
| 1227 | + "id": "106", |
| 1228 | + "metadata": {}, |
| 1229 | + "outputs": [], |
| 1230 | + "source": [ |
| 1231 | + "gdf = leafmap.geojson_to_gdf(tree_boundaries)\n", |
| 1232 | + "gdf.head()" |
| 1233 | + ] |
| 1234 | + }, |
| 1235 | + { |
| 1236 | + "cell_type": "code", |
| 1237 | + "execution_count": null, |
| 1238 | + "id": "107", |
| 1239 | + "metadata": {}, |
| 1240 | + "outputs": [], |
| 1241 | + "source": [ |
| 1242 | + "geojson = \"tree_boundaries.geojson\"\n", |
| 1243 | + "gdf.to_file(geojson)" |
| 1244 | + ] |
| 1245 | + }, |
| 1246 | + { |
| 1247 | + "cell_type": "code", |
| 1248 | + "execution_count": null, |
| 1249 | + "id": "108", |
| 1250 | + "metadata": {}, |
| 1251 | + "outputs": [], |
| 1252 | + "source": [ |
| 1253 | + "m = leafmap.Map()\n", |
| 1254 | + "m.add_raster(image, layer_name=\"image\")\n", |
| 1255 | + "style = {\n", |
| 1256 | + " \"color\": \"#ffff00\",\n", |
| 1257 | + " \"weight\": 2,\n", |
| 1258 | + " \"fillColor\": \"#7c4185\",\n", |
| 1259 | + " \"fillOpacity\": 0,\n", |
| 1260 | + "}\n", |
| 1261 | + "m.add_vector(geojson, style=style, zoom_to_layer=True, layer_name=\"Bounding boxes\")\n", |
| 1262 | + "m" |
| 1263 | + ] |
| 1264 | + }, |
| 1265 | + { |
| 1266 | + "cell_type": "code", |
| 1267 | + "execution_count": null, |
| 1268 | + "id": "109", |
| 1269 | + "metadata": {}, |
| 1270 | + "outputs": [], |
| 1271 | + "source": [ |
| 1272 | + "sam = SamGeo(\n", |
| 1273 | + " model_type=\"vit_h\",\n", |
| 1274 | + " automatic=False,\n", |
| 1275 | + " sam_kwargs=None,\n", |
| 1276 | + ")" |
| 1277 | + ] |
| 1278 | + }, |
| 1279 | + { |
| 1280 | + "cell_type": "code", |
| 1281 | + "execution_count": null, |
| 1282 | + "id": "110", |
| 1283 | + "metadata": {}, |
| 1284 | + "outputs": [], |
| 1285 | + "source": [ |
| 1286 | + "sam.set_image(image)" |
| 1287 | + ] |
| 1288 | + }, |
| 1289 | + { |
| 1290 | + "cell_type": "code", |
| 1291 | + "execution_count": null, |
| 1292 | + "id": "111", |
| 1293 | + "metadata": {}, |
| 1294 | + "outputs": [], |
| 1295 | + "source": [ |
| 1296 | + "sam.predict(\n", |
| 1297 | + " boxes=geojson, point_crs=\"EPSG:4326\", output=\"tree_masks.tif\", dtype=\"uint16\"\n", |
| 1298 | + ")" |
| 1299 | + ] |
| 1300 | + }, |
| 1301 | + { |
| 1302 | + "cell_type": "code", |
| 1303 | + "execution_count": null, |
| 1304 | + "id": "112", |
| 1305 | + "metadata": {}, |
| 1306 | + "outputs": [], |
| 1307 | + "source": [ |
| 1308 | + "m.add_raster(\n", |
| 1309 | + " \"tree_masks.tif\", cmap=\"jet\", nodata=0, opacity=0.5, layer_name=\"Tree masks\"\n", |
| 1310 | + ")\n", |
| 1311 | + "m" |
| 1312 | + ] |
| 1313 | + }, |
| 1314 | + { |
| 1315 | + "cell_type": "markdown", |
| 1316 | + "id": "113", |
| 1317 | + "metadata": {}, |
| 1318 | + "source": [ |
| 1319 | + "" |
| 1320 | + ] |
1215 | 1321 | }
|
1216 | 1322 | ],
|
1217 | 1323 | "metadata": {
|
1218 | 1324 | "colab": {
|
1219 | 1325 | "provenance": []
|
1220 | 1326 | },
|
1221 | 1327 | "kernelspec": {
|
1222 |
| - "display_name": "Python 3 (ipykernel)", |
| 1328 | + "display_name": "sam", |
1223 | 1329 | "language": "python",
|
1224 | 1330 | "name": "python3"
|
1225 | 1331 | },
|
|
0 commit comments