{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Automatic Building Footprint Extraction Using Satellite RGB and LiDAR Elevation\n", "\n", "In this notebook, we will show how to utilize both SpaceNet satellite image and USGS 3DEP LiDAR data (elevation attribute) to automatically extract building footprints. This task was used in three previous SpaceNet challenges: 1st, 2nd, and 4th." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup\n", "\n", "_This notebook was created and tested on an ml.p3.8xlarge notebook instance._\n", "\n", "First of all, if you haven't done so, please follow instructions in `README.md` to run `setup-env.sh` and `download-from-s3.sh` scripts to properly set up the Conda environment and download necessary files from S3 buckets prepared for this tutorial. Before proceeding, make sure this notebook connects with the proper kernel (`conda_[name]`, `[name]` is name of the new Conda environment you just created)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os, time, json, random\n", "from pathlib import Path\n", "from tqdm import tqdm\n", "from p_tqdm import p_umap\n", "import numpy as np\n", "import pandas as pd\n", "import skimage\n", "import torch\n", "from torch import nn\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\", category=FutureWarning)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### External modules\n", "\n", "We made some customized modification to the external module `solaris` in `libs/` directory. Please refer to their [GitHub page](https://github.com/CosmiQ/solaris) for more information." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2022-11-06 10:09:42.843904: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA\n", "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n", "2022-11-06 10:09:43.751558: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n" ] } ], "source": [ "import libs.solaris as sol" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plotting preferences" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_14714/3301049148.py:5: MatplotlibDeprecationWarning: The seaborn styles shipped by Matplotlib are deprecated since 3.6, as they no longer correspond to the styles shipped by seaborn. However, they will remain available as 'seaborn-v0_8-\n", "
\n", " | class_id | \n", "iou_field | \n", "TruePos | \n", "FalsePos | \n", "FalseNeg | \n", "Precision | \n", "Recall | \n", "F1Score | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "all | \n", "iou_score_all | \n", "26 | \n", "4 | \n", "5 | \n", "0.866667 | \n", "0.83871 | \n", "0.852459 | \n", "