本文主要是介绍SpaceNet 建筑物检测,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
SpaceNet 建筑物检测
该存储库提供了一些 python 脚本和 jupyter 笔记本来训练和评估从SpaceNet卫星图像中提取建筑物的卷积神经网络。
用法
0. 克隆repo
$ PROJ_DIR=~/spacenet_building_detection # assuming you clone this repo to your home directory
$ git clone --recursive https://github.com/motokimura/spacenet_building_detection.git $PROJ_DIR
1.下载SpaceNet数据集
下载卫星图像和地面实况建筑物足迹(SpaceNet AOI-1 Rio)。假设您已经将AWS CLI配置 为从 AWS S3 下载数据。
$ cd $PROJ_DIR/data
# Download processed 200mx200m tiles of AOI 1 (3.4 GB) with associated building footprints
$ aws s3api get-object --bucket spacenet-dataset --key AOI_1_Rio/processedData/processedBuildingLabels.tar.gz --request-payer requester processedBuildingLabels.tar.gz
$ tar -xvf processedBuildingLabels.tar.gz
$ cd processedBuildingLabels
$ tar -xvf 3band.tar.gz
$ cd vectordata
$ tar -xvf geojson.tar.gz
# Download the Source Imagery Mosaic (3-band = 2.3 GB and 8-band = 6.5 GB)
$ cd $PROJ_DIR/data
$ aws s3api get-object --bucket spacenet-dataset --key AOI_1_Rio/srcData/rasterData/3-Band.tar.gz --request-payer requester 3-Band.tar.gz
$ tar -xvf 3-Band.tar.gz
您可以在此处找到更多详细信息。
2.构建Docker镜像
构建 docker 镜像以设置环境以预处理 SpaceNet 数据集并训练/评估卷积神经网络。
$ cd $PROJ_DIR/docker
$ bash build.sh
我强烈推荐你使用 docker,因为你可能会在安装一些地理空间数据处理库时遇到一些麻烦。如果您不想使用 docker,则必须安装Dockerfile中描述的其他依赖项。
3.预处理SpaceNet数据集
将 GeoJSON 中的 SpaceNet 地面实况建筑物足迹转换为建筑物遮罩图像。
通过以下方式运行 docker 容器:
$ cd $PROJ_DIR/docker
$ bash run.sh
现在你应该在你运行的 docker 容器中。通过以下方式转换 SpaceNet 数据集:
$(docker) cd /workspace/src/features
$(docker) python build_labels.py ../../data/processedBuildingLabels/3band ../../data/processedBuildingLabels/vectordata/geojson ../../data/buildingMaskImages
$PROJ_DIR/data/processedBuildingLabels/3band现在你会在和中分别找到许多对卫星图像和建筑物遮罩图像,$PROJ_DIR/data/buildingMaskImages如下所示:
4.训练U-Net
训练U-Net,一种最初为医学图像分割而开发的卷积神经网络。
通过以下方式使用 SpaceNet 数据集训练 U-Net:
$(docker) cd /workspace/src/models
$(docker) python train_model.py ../../data/dataSplit ../../data/processedBuildingLabels/3band ../../data/buildingMaskImages
您可以从 TensorBoard 检查训练状态和验证准确性:
# Open another terminal window outside the container and type:
$ cd $PROJ_DIR/docker
$ bash exec.sh
# Now you should be inside the container already running. Start TensorBoard by following:
$(docker) tensorboard --logdir /workspace/models
然后,http://localhost:6006从您的浏览器打开。
5. 评估 U-Net
使用 jupyter notebook 评估 U-Net。
通过以下方式启动 jupyter notebook:
$(docker) cd /workspace/notebooks
$(docker) jupyter notebook
然后,http://localhost:8888从您的浏览器打开。
默认密码在Dockerfilepassw0rd中定义。
请注意,您可能需要修改下面笔记本中定义的预训练模型的路径。
5.1 定量评价
打开这个笔记本。
5.2 测试瓦片图像的定性评价
打开此笔记本 以查看 test-plit 中平铺图像的分割结果。
输出示例:
5.3 对图像的定性评价
打开此笔记本 以查看源图像的分割结果。
输出示例:
https://github.com/motokimura/spacenet_building_detection
这篇关于SpaceNet 建筑物检测的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!