From c746cac1f7c7715ee2b82b046ad019a6da0cb7b4 Mon Sep 17 00:00:00 2001 From: Nils Lehmann <35272119+nilsleh@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:19:36 +0100 Subject: [PATCH] Add SpaceNet6 datamodule (#2367) * spacenet 6 datamodule * datamodule base class * mypy * fix tests * fix docs * fix tests again * uncomment test * magic comma * review * class -> instance --------- Co-authored-by: Adam J. Stewart --- docs/api/datamodules.rst | 2 + tests/conf/spacenet1.yaml | 2 +- tests/conf/spacenet6.yaml | 19 ++ ...SN1_buildings_train_AOI_1_Rio_3band.tar.gz | Bin 653 -> 0 bytes ...SN1_buildings_train_AOI_1_Rio_8band.tar.gz | Bin 643 -> 0 bytes ...s_train_AOI_1_Rio_geojson_buildings.tar.gz | Bin 525 -> 0 bytes tests/data/spacenet/data.py | 92 ---------- .../test}/3band/3band_AOI_1_RIO_img1.tif | Bin .../test}/3band/3band_AOI_1_RIO_img2.tif | Bin .../test}/3band/3band_AOI_1_RIO_img3.tif | Bin .../test}/3band/3band_AOI_1_RIO_img4.tif | Bin .../test/8band/8band_AOI_1_RIO_img1.tif} | Bin .../test/8band/8band_AOI_1_RIO_img2.tif} | Bin .../test/8band/8band_AOI_1_RIO_img3.tif} | Bin .../test/8band/8band_AOI_1_RIO_img4.tif} | Bin .../SN1_buildings_test_AOI_1_Rio_3band.tar.gz | Bin 0 -> 615 bytes .../SN1_buildings_test_AOI_1_Rio_8band.tar.gz | Bin 0 -> 615 bytes .../train/3band/3band_AOI_1_RIO_img1.tif | Bin 0 -> 390 bytes .../train/3band/3band_AOI_1_RIO_img2.tif | Bin 0 -> 390 bytes .../train/3band/3band_AOI_1_RIO_img3.tif | Bin 0 -> 390 bytes .../train/3band/3band_AOI_1_RIO_img4.tif | Bin 0 -> 390 bytes .../train/8band/8band_AOI_1_RIO_img1.tif | Bin 0 -> 456 bytes .../train/8band/8band_AOI_1_RIO_img2.tif | Bin 0 -> 456 bytes .../train/8band/8band_AOI_1_RIO_img3.tif | Bin 0 -> 456 bytes .../train/8band/8band_AOI_1_RIO_img4.tif | Bin 0 -> 456 bytes ...SN1_buildings_train_AOI_1_Rio_3band.tar.gz | Bin 0 -> 620 bytes ...SN1_buildings_train_AOI_1_Rio_8band.tar.gz | Bin 0 -> 620 bytes ...s_train_AOI_1_Rio_geojson_buildings.tar.gz | Bin 0 -> 515 bytes .../train/geojson/Geo_AOI_1_RIO_img1.geojson | 0 .../train/geojson/Geo_AOI_1_RIO_img2.geojson | 0 .../train/geojson/Geo_AOI_1_RIO_img3.geojson | 0 .../train/geojson/Geo_AOI_1_RIO_img4.geojson | 1 + tests/data/spacenet/spacenet1/data.py | 161 +++++++++++++++++ ...SN6_buildings_AOI_11_Rotterdam_test.tar.gz | Bin 0 -> 714 bytes ...y_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 410 bytes ...N6_buildings_AOI_11_Rotterdam_train.tar.gz | Bin 0 -> 1665 bytes ...N_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 370 bytes ...N_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 370 bytes ...N_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 370 bytes ...N_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 370 bytes ...B_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 390 bytes ...B_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 390 bytes ...B_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 390 bytes ...B_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 390 bytes ...R_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 410 bytes ...R_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_1.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_2.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_3.tif | Bin 0 -> 410 bytes ...y_20190804111224_20190804111453_tile_4.tif | Bin 0 -> 410 bytes ...190804111224_20190804111453_tile_1.geojson | 0 ...190804111224_20190804111453_tile_2.geojson | 1 + ...190804111224_20190804111453_tile_3.geojson | 0 ...190804111224_20190804111453_tile_4.geojson | 1 + tests/data/spacenet/spacenet6/data.py | 171 ++++++++++++++++++ tests/datasets/test_spacenet.py | 64 ++++--- tests/trainers/test_segmentation.py | 1 + torchgeo/datamodules/__init__.py | 4 +- torchgeo/datamodules/spacenet.py | 155 ++++++++++++---- 68 files changed, 521 insertions(+), 153 deletions(-) create mode 100644 tests/conf/spacenet6.yaml delete mode 100644 tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_3band.tar.gz delete mode 100644 tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_8band.tar.gz delete mode 100644 tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz delete mode 100755 tests/data/spacenet/data.py rename tests/data/spacenet/{SN1_buildings/train => spacenet1/SN1_buildings/test}/3band/3band_AOI_1_RIO_img1.tif (100%) rename tests/data/spacenet/{SN1_buildings/train => spacenet1/SN1_buildings/test}/3band/3band_AOI_1_RIO_img2.tif (100%) rename tests/data/spacenet/{SN1_buildings/train => spacenet1/SN1_buildings/test}/3band/3band_AOI_1_RIO_img3.tif (100%) rename tests/data/spacenet/{SN1_buildings/train => spacenet1/SN1_buildings/test}/3band/3band_AOI_1_RIO_img4.tif (100%) rename tests/data/spacenet/{SN1_buildings/train/8band/3band_AOI_1_RIO_img1.tif => spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img1.tif} (100%) rename tests/data/spacenet/{SN1_buildings/train/8band/3band_AOI_1_RIO_img2.tif => spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img2.tif} (100%) rename tests/data/spacenet/{SN1_buildings/train/8band/3band_AOI_1_RIO_img3.tif => spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img3.tif} (100%) rename tests/data/spacenet/{SN1_buildings/train/8band/3band_AOI_1_RIO_img4.tif => spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img4.tif} (100%) create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/test/SN1_buildings_test_AOI_1_Rio_3band.tar.gz create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/test/SN1_buildings_test_AOI_1_Rio_8band.tar.gz create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/3band/3band_AOI_1_RIO_img1.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/3band/3band_AOI_1_RIO_img2.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/3band/3band_AOI_1_RIO_img3.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/3band/3band_AOI_1_RIO_img4.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/8band/8band_AOI_1_RIO_img1.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/8band/8band_AOI_1_RIO_img2.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/8band/8band_AOI_1_RIO_img3.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/8band/8band_AOI_1_RIO_img4.tif create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_3band.tar.gz create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_8band.tar.gz create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz rename tests/data/spacenet/{ => spacenet1}/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img1.geojson (100%) rename tests/data/spacenet/{ => spacenet1}/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img2.geojson (100%) rename tests/data/spacenet/{ => spacenet1}/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img3.geojson (100%) create mode 100644 tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img4.geojson create mode 100755 tests/data/spacenet/spacenet1/data.py create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/test/SN6_buildings_AOI_11_Rotterdam_test.tar.gz create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/SN6_buildings_AOI_11_Rotterdam_train.tar.gz create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_1.geojson create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_2.geojson create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_3.geojson create mode 100644 tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_4.geojson create mode 100644 tests/data/spacenet/spacenet6/data.py diff --git a/docs/api/datamodules.rst b/docs/api/datamodules.rst index a4afe8c366..abb0c6eaef 100644 --- a/docs/api/datamodules.rst +++ b/docs/api/datamodules.rst @@ -193,7 +193,9 @@ So2Sat SpaceNet ^^^^^^^^ +.. autoclass:: SpaceNetBaseDataModule .. autoclass:: SpaceNet1DataModule +.. autoclass:: SpaceNet6DataModule SSL4EO ^^^^^^ diff --git a/tests/conf/spacenet1.yaml b/tests/conf/spacenet1.yaml index 275e54eee0..6f47d88d35 100644 --- a/tests/conf/spacenet1.yaml +++ b/tests/conf/spacenet1.yaml @@ -15,4 +15,4 @@ data: val_split_pct: 0.34 test_split_pct: 0.34 dict_kwargs: - root: 'tests/data/spacenet' + root: 'tests/data/spacenet/spacenet1' diff --git a/tests/conf/spacenet6.yaml b/tests/conf/spacenet6.yaml new file mode 100644 index 0000000000..c017102d3d --- /dev/null +++ b/tests/conf/spacenet6.yaml @@ -0,0 +1,19 @@ +model: + class_path: SemanticSegmentationTask + init_args: + loss: 'ce' + model: 'unet' + backbone: 'resnet18' + in_channels: 4 + num_classes: 3 + num_filters: 1 + ignore_index: null +data: + class_path: SpaceNet6DataModule + init_args: + batch_size: 1 + val_split_pct: 0.34 + test_split_pct: 0.34 + dict_kwargs: + root: 'tests/data/spacenet/spacenet6' + image: 'SAR-Intensity' diff --git a/tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_3band.tar.gz b/tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_3band.tar.gz deleted file mode 100644 index 78352e2c5f3254b2aacf8d9ff915fe100735939e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 653 zcmV;80&@KyiwFovUchDo|5HveUt)D>Y-DL}XLDb4a$#w1UqMevUol@&X>VUMVqtD% zE_7jX0PUE+Z__{&$InUBnh;fG02Yuem|$@3&i2_IsFDG-nTjY944}wS5|qIV!JrBu zMFJ!$6!k ztFAy;Q6BUUe{W*ESdQ?&4 zwPd^z71Y)Dwej8PYSGm4DSZBNX=i)!R_p%FFYmV(|Mev1mNz%QeZ0K&_WOl!_p{jg z*{-RpoF$|b#|5I5k~Tf|yYrg95zWTWLv24he@tJG;{C^!C*)}mzBv1;Uz1_&^|c%I z>r1PKXFnvP(WqQ54+ewbaF}=fxA)HfIP^ag{rC3M{{@fZ6CmIE&!?;ZE`|O>|Dpf+ z(0}~@J!JoX8E26HTY-DL}XLDb4a$#w1UqMevUol@&X>VURVqtD% zE_7jX0PUH-YZGA@$KOjrJZmU+ur3M*PC8uP_kJ%e$slc}mR8U~30IOxhI5FgbP$9p zTn8x~#JPirgJ3%sp?`uDCr7~!I=Sf}_`H`Fyrx!{Cc)nKbG-LFdGo&Sak+b+&k(a} zR%?sl>U=wFwR>zR@IJ>y&TZ#+F8c+ygvE?iHUb{pkHa2ap5+rOFrv5{wP%EH*+F3Q zfSZnQ(_?Ta7&!F=E8)FXb-34%o7(r?e)Rg0TZi|&a6FIRIbVo$|9g&LhC9mrUvGuc z-^S6fPUrMJe-rf|_5Voy=UfB=^*=ZD-99;0yQm@7buq_K2j^He%Z>Id`c^&@im<;sD3$T zII_rK)|H-P{1?0oXc6$I&0080!Ofdie diff --git a/tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz b/tests/data/spacenet/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz deleted file mode 100644 index 188996278353c9a7338130acf3922f2fb400ca54..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 525 zcmV+o0`mPIiwFovUchDo|5HveUt)D>Y-DL}XLDb4a$#w1UqMevUol@&X>VU=Wp8S8 zZ*E^=b!lv5X>Mn8E_7jX0PUAeYvV8whJD^&A$(4i(T63+u+S3NZci!QV+g?{N^ps- zpg7R5_`g@K(@k5qg@x9IdY+4nW=3PM=Y4HDq{H*;^zOGwm&OI30yMm}0tk7!uJ;*m z#shK}bijUBrp~ty`U#IoUS_%Z$ut*nEFcCdwTxrnKLX_2vo`j2XN%!y_Na$i>!?{( zvjTrU^GqrQ5NXEh`DcQ$fJ9x+|HU%R-^=r9tJU{={uK2e^}ntEDuNN}e~H+maiE-hCXKgm6HFV|B)6^Kmhe0^&j>BOTPaZNYwv6>p$;K{}pE~{g)c` zzYG3`k>;k}-#WWBuFOmme%SWmy(<#C zUL;GiN_=TDxf~~qie!BACzfGV`N~z(rmmZ|n%77B*Dg1uJ3Q-qZ8wMY@s_N0%dAMt z=8Wm|ObV(s2cg)2oN-P^+%uA+2cmdDfWmA*{v|4T%F|rFjC=PHP3@CBsUP=r>pU%w zz4Vg;kgApV{vFO{RW+-6>Hnhb{|x=V6aUw*`@dFb|GoBq@x}jt=>G_UAP9mW2!bF8 P@?qQqEiIlW04M+eJueXi diff --git a/tests/data/spacenet/data.py b/tests/data/spacenet/data.py deleted file mode 100755 index 4d99e415e6..0000000000 --- a/tests/data/spacenet/data.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import json -import os -import shutil - -import numpy as np -import rasterio -from rasterio.crs import CRS -from rasterio.transform import Affine - -SIZE = 2 - -dataset_id = 'SN1_buildings' - -profile = { - 'driver': 'GTiff', - 'dtype': 'uint8', - 'width': SIZE, - 'height': SIZE, - 'crs': CRS.from_epsg(4326), - 'transform': Affine( - 4.489235388119662e-06, - 0.0, - -43.7732462563, - 0.0, - -4.486127586210932e-06, - -22.9214851954, - ), -} - -np.random.seed(0) -Z = np.random.randint(np.iinfo('uint8').max, size=(SIZE, SIZE), dtype='uint8') - -for count in [3, 8]: - os.makedirs(os.path.join(dataset_id, 'train', f'{count}band'), exist_ok=True) - for i in range(1, 5): - path = os.path.join( - dataset_id, 'train', f'{count}band', f'3band_AOI_1_RIO_img{i}.tif' - ) - profile['count'] = count - with rasterio.open(path, 'w', **profile) as src: - for j in range(1, count + 1): - src.write(Z, j) - - shutil.make_archive( - os.path.join(dataset_id, 'train', f'SN1_buildings_train_AOI_1_Rio_{count}band'), - 'gztar', - os.path.join(dataset_id, 'train'), - f'{count}band', - ) - -geojson = { - 'type': 'FeatureCollection', - 'crs': {'type': 'name', 'properties': {'name': 'urn:ogc:def:crs:OGC:1.3:CRS84'}}, - 'features': [ - { - 'type': 'Feature', - 'geometry': { - 'type': 'Polygon', - 'coordinates': [ - [ - [-43.7720361, -22.922229499999958, 0.0], - [-43.772064, -22.9222724, 0.0], - [-43.772102399999937, -22.922247399999947, 0.0], - [-43.772074499999974, -22.9222046, 0.0], - [-43.7720361, -22.922229499999958, 0.0], - ] - ], - }, - } - ], -} - -os.makedirs(os.path.join(dataset_id, 'train', 'geojson'), exist_ok=True) -for i in range(1, 4): - path = os.path.join(dataset_id, 'train', 'geojson', f'Geo_AOI_1_RIO_img{i}.geojson') - with open(path, 'w') as src: - if i % 2 == 0: - json.dump(geojson, src) - -shutil.make_archive( - os.path.join( - dataset_id, 'train', 'SN1_buildings_train_AOI_1_Rio_geojson_buildings' - ), - 'gztar', - os.path.join(dataset_id, 'train'), - 'geojson', -) diff --git a/tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img1.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img1.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img1.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img1.tif diff --git a/tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img2.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img2.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img2.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img2.tif diff --git a/tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img3.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img3.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img3.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img3.tif diff --git a/tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img4.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img4.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/3band/3band_AOI_1_RIO_img4.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/3band/3band_AOI_1_RIO_img4.tif diff --git a/tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img1.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img1.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img1.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img1.tif diff --git a/tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img2.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img2.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img2.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img2.tif diff --git a/tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img3.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img3.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img3.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img3.tif diff --git a/tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img4.tif b/tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img4.tif similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/8band/3band_AOI_1_RIO_img4.tif rename to tests/data/spacenet/spacenet1/SN1_buildings/test/8band/8band_AOI_1_RIO_img4.tif diff --git a/tests/data/spacenet/spacenet1/SN1_buildings/test/SN1_buildings_test_AOI_1_Rio_3band.tar.gz b/tests/data/spacenet/spacenet1/SN1_buildings/test/SN1_buildings_test_AOI_1_Rio_3band.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..34d22b20d09ee5f92a757c6989cef074566b5180 GIT binary patch literal 615 zcmb2|=HOWLP&S?Ef3Tlnd{Sv-tqrYdoVSG?#e!Ou~VqS_~Nn#Ph z+v)qWg%c%?-#6!cYuXmn{wnC<1<&@=zwh;b-xP7l@s^LM_KO8AEpD7M_+Dzdwlr{E zS1b`qXD{TsanAKcyh4zbC0AMDrL&G7D(}y$(%9O)cg4@TzVGwY-|zjd%zpm!!#SIR z*TvYe)Z)5m+x;-wO7R;LU;T>4mj*4tiW;qsPGv9bS8E&av6 zY0dws-{xMuzt;NI5Bsj>fBpadd;kBw;=lHn{}W&SPm7-)z2<7_U$5Ma_uk!^=67Y^ z*XOU|HUD4u=O6oj`M>w86%w|c*!0hR%m3?H;xk+eyA0>0&)FoyJMUESl;@iJmQD13 z_Eo}rt>sB>wf+9PU#7&(FV@=ntYp(Nmt?ilxl5n?sy0!RpX&2(+OfmORn6Q!3inPg zoOe^?{3XuWg(qXyd;ScYW9)zbDf|CpM$+cDf4?}n`RCrdH)o%%Hn-b%bFS?xUmv}k z{QA1`%;#69f4=ySee37kd9#|zT%DGF0^(Q&Pi?2VM{-*1H120>1(#9LFzyA7b_lN)gq7~zo}>a ufB63gd!W$a{|d$btDV2qbD)U)KKymR5Lf{-11>P(nf8hnlJ|5HveUt)D>Y-DL}XLDb4Wpi|2K~G6vF<(+?Z(lfKVQyqD zbYXG;?boqu6Hy!o@ZTjNo;4IZSQmu@Cmk;D-MxD+izOYT&D7EgIw&EfQ39qzdP)bO zpu#zbIEZrx5eLC`E<*nVDNc@p9dvTjLGZonL(f3%(p;$devWtVmzTSDT;RPg@vDBd zKHplKZMT-&JsJqM@1UNsQ2eRQIA;M5$XlZv++B@ZJ^gqZO+n4;#+`2aGFKsEoJW!H zdBAG{Q)2}Gz1mW1Ww|=oXP8B;RAhRtqA=V4Uh`Zirb5Z22+aDIfg&%;bN#P$?yUan zy2HLdrhM%G*#G`XAB#ztOlvuI?v@oFX~8D(L29>VmG#6(4mg+Hup$nR>!0rTuGtI%CJpJ(HPv z&f04{-Ogq1UC{Lj-G9+-(LU?DZsQLtR5bJGiyl0xP}$t8>$gcUonv0tn@J^|`Zr|}Yr|E4ZR?{}vT``yN8x3_xqT@NB-mg9~@c!2Sd((f&54QBma^A$baNN-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cNF>YK%0Ty0Gki8n33U`03*l7cAzW+8<^jx%*nB#9i)dF rOfxWa-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cNF>YK%0Ty0Gki8n33U`03*l7cAzW+8<^jx%*nB#9i)dF rOfxWa-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cNF>YK%0Ty0Gki8n33U`03*l7cAzW+8<^jx%*nB#9i)dF rOfxWa-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cNF>YK%0Ty0Gki8n33U`03*l7cAzW+8<^jx%*nB#9i)dF rOfxWa-nFRNMk$W~eww9UBr`kdXzfcLh*F6egvCsfCAu4aimive&mW zGbjMr0YLVKb{?>MCji+S+nK<67XaBHz<~xKqA-#X=w4*_v}DQx_bZp|Vw1{ZK3=$F z2UCZO=JVLS`{yIq1AG5!mOOiHb^xXhWF`a1KP-nFRNMk$W~eww9UBr`kdXzfcLh*F6egvCsfCAu4aimive&mW zGbjMr0YLVKb{?>MCji+S+nK<67XaBHz<~xKqA-#X=w4*_v}DQx_bZp|Vw1{ZK3=$F z2UCZO=JVLS`{yIq1AG5!mOOiHb^xXhWF`a1KP-nFRNMk$W~eww9UBr`kdXzfcLh*F6egvCsfCAu4aimive&mW zGbjMr0YLVKb{?>MCji+S+nK<67XaBHz<~xKqA-#X=w4*_v}DQx_bZp|Vw1{ZK3=$F z2UCZO=JVLS`{yIq1AG5!mOOiHb^xXhWF`a1KP-nFRNMk$W~eww9UBr`kdXzfcLh*F6egvCsfCAu4aimive&mW zGbjMr0YLVKb{?>MCji+S+nK<67XaBHz<~xKqA-#X=w4*_v}DQx_bZp|Vw1{ZK3=$F z2UCZO=JVLS`{yIq1AG5!mOOiHb^xXhWF`a1KPlJ|5HveUt)D>Y-DL}XLDb4a$#w1UqMevUol@&X>VUMVqtD% zE_7jX0PUE+YZGA@$KOjrd&W@epe_oBPC8uP_wK#-;?R-~(q^hyK?fxyG)lm9NKYvu z1XQ>Vp;K{o5T}6cT!j7wBBhg~U>7Id90Z^D?Wu=SyV#4G@8@{$dGg+SKXULqA2_${ zmaA79D|4;JVynxJ1isHfk#k@E$o0J7p75Bn!ZP6Aa@6S3?b&GJRh&-L?zE;v=yNVa z5J*?>OBIi+A_MH1e5)qjv>{V%oe zF8^-bVaNYbT=akR|6lrlK>c5$|Bp=nH~ad`e623(S8Mb2cIS?8qxS7TSN}@M1N%R9 z{h#{3R6)QTo@M=yX#cO(E;5_qBx6>dS(N2ySgAZmd7k2H8u?^ikFnI66IQ|G4`_EX znb+r>O07AatSQkrle*4Aa{XNz6OT(Ke@o-hlM)-F_=(2LIL{o4=jeouxMZ%^q`hF}ZEbyicX|8OmkZI}2etie-ZD=) z&R9X`Ic61-Ia|lQNz2}h$MyR#zt_$mvo~UW{J4pXt#+cPXP!~fa)AK!mR-v9oP{U5^r@IU+y z|HJ?AKgitwa=89i9R7#@;eP-C000000000000000000000000000000(tHIPOEUcc GPyhf{YeLrm literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_8band.tar.gz b/tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_8band.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6eaebc3a9ade7d7224000e8a9028a87ccfd329b7 GIT binary patch literal 620 zcmV-y0+an8iwFp!;T>lJ|5HveUt)D>Y-DL}XLDb4a$#w1UqMevUol@&X>VURVqtD% zE_7jX0PWbZYZFl%2k_q|Aw6p-cBn222TnR%-n)DEE)JG-kTz3GE9g)ODUBu2bVyI> zAP6d)gNTDTcMx$9Z092MPmto|DA++Kw{|G_-u0nppmu34wE2FHckh>%yLVjRy)VQq zyXERkV{NM0SZsEvC)lB*dd7V5x7OpFdE6ssjWY0HHEML!<7qH?6{j7w+Rd9h^cmwk z2!zYIU-6h6COGpd3yqbokHeGMEm$)0X?w{QHmr@+L|A)ML z{})pFEElJji zTujY#$z0>8b~$zLtg44p|3kGo^Q=A9MxK@^ujf%0J$Y85qP|zvALD#7$Be2s;!-mA zD^+jCx#Zq;>+sF&uH#=;*YQ1iy*~M6XZ+s6!}(vIcgBzV-A1Oiw)Vf>+WvHKE!zDl zx6|{IexHJ_b7U3Fn63NW3zoeZ>$fc?pI=@*XK%#%`}0Xp^t>Itx$?GCRb}N?5* GPyhhz(nyQ| literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz b/tests/data/spacenet/spacenet1/SN1_buildings/train/SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ed4f60826e0f2bc0f16809b0f5b54afb863e5984 GIT binary patch literal 515 zcmV+e0{s0SiwFp!;T>lJ|5HveUt)D>Y-DL}XLDb4a$#w1UqMevUol@&X>VU=Wp8S8 zZ*E^=b!lv5X>Mn8E_7jX0PUCEOT#b_!29f95&Ar{d^NWf1ZCjI(?lP~7-fs2vNj{@ zz#;wLP3?5kp(3~r^?olIxl67OyWbJortQ<~GfAl~4AN^nZUo_``E%=WAWrY53g2%8}%}p4S@Z2QD z(wUx}&CIw+Z63BrICcvk+a%>lW~%+UvvcE$)YReUZ698`JhszuJTZ5%KN|NhdNHRm z?%mvWR9Ke&P_8iJ6lcHpJc6@qTv9q~yrOYob=0JP_)A+)p1_pWVt+@UjOx_kmj1f~^Bg>7B&Szi>D# z%VCN0ALl>Lf8@~fUmp1Vhw~r(kN!vhBZu+7I`I1s(Es@U!}lM8AP9o&gD1|2W3&J$ F004*r3|s&J literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img1.geojson b/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img1.geojson similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img1.geojson rename to tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img1.geojson diff --git a/tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img2.geojson b/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img2.geojson similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img2.geojson rename to tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img2.geojson diff --git a/tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img3.geojson b/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img3.geojson similarity index 100% rename from tests/data/spacenet/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img3.geojson rename to tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img3.geojson diff --git a/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img4.geojson b/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img4.geojson new file mode 100644 index 0000000000..dabcc4ce30 --- /dev/null +++ b/tests/data/spacenet/spacenet1/SN1_buildings/train/geojson/Geo_AOI_1_RIO_img4.geojson @@ -0,0 +1 @@ +{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[-43.7720361, -22.922229499999958, 0.0], [-43.772064, -22.9222724, 0.0], [-43.77210239999994, -22.922247399999947, 0.0], [-43.772074499999974, -22.9222046, 0.0], [-43.7720361, -22.922229499999958, 0.0]]]}}]} \ No newline at end of file diff --git a/tests/data/spacenet/spacenet1/data.py b/tests/data/spacenet/spacenet1/data.py new file mode 100755 index 0000000000..f8187583cc --- /dev/null +++ b/tests/data/spacenet/spacenet1/data.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import hashlib +import json +import os +import shutil +from typing import Any + +import numpy as np +import rasterio +from rasterio.crs import CRS +from rasterio.transform import Affine + +SIZE = 2 + +NUM_SAMPLES = 4 + +dataset_id = 'SN1_buildings' + +profile = { + 'driver': 'GTiff', + 'dtype': 'uint8', + 'width': SIZE, + 'height': SIZE, + 'crs': CRS.from_epsg(4326), + 'transform': Affine( + 4.489235388119662e-06, + 0.0, + -43.7732462563, + 0.0, + -4.486127586210932e-06, + -22.9214851954, + ), +} + +np.random.seed(0) +Z = np.random.randint(np.iinfo('uint8').max, size=(SIZE, SIZE), dtype='uint8') + + +def create_directories(base_path: str, band_counts: list[int]) -> None: + for count in band_counts: + os.makedirs(os.path.join(base_path, f'{count}band'), exist_ok=True) + + +def generate_geotiff_files( + base_path: str, band_counts: list[int], profile: dict[str, Any], Z: np.ndarray +) -> None: + for count in band_counts: + for i in range(1, NUM_SAMPLES + 1): + path = os.path.join( + base_path, f'{count}band', f'{count}band_AOI_1_RIO_img{i}.tif' + ) + profile['count'] = count + with rasterio.open(path, 'w', **profile) as src: + for j in range(1, count + 1): + src.write(Z, j) + + +def generate_geojson_files(base_path: str, geojson: dict[str, Any]) -> None: + os.makedirs(os.path.join(base_path, 'geojson'), exist_ok=True) + for i in range(1, NUM_SAMPLES + 1): + path = os.path.join(base_path, 'geojson', f'Geo_AOI_1_RIO_img{i}.geojson') + with open(path, 'w') as src: + if i % 2 == 0: + json.dump(geojson, src) + + +def compute_md5(file_path: str) -> str: + hash_md5 = hashlib.md5() + with open(file_path, 'rb') as f: + for chunk in iter(lambda: f.read(4096), b''): + hash_md5.update(chunk) + return hash_md5.hexdigest() + + +# Generate dummy GeoJSON files for building footprints +geojson = { + 'type': 'FeatureCollection', + 'crs': {'type': 'name', 'properties': {'name': 'urn:ogc:def:crs:OGC:1.3:CRS84'}}, + 'features': [ + { + 'type': 'Feature', + 'geometry': { + 'type': 'Polygon', + 'coordinates': [ + [ + [-43.7720361, -22.922229499999958, 0.0], + [-43.772064, -22.9222724, 0.0], + [-43.772102399999937, -22.922247399999947, 0.0], + [-43.772074499999974, -22.9222046, 0.0], + [-43.7720361, -22.922229499999958, 0.0], + ] + ], + }, + } + ], +} + +# Remove existing data if it exists +if os.path.exists(dataset_id): + shutil.rmtree(dataset_id) + +train_base_path = os.path.join(dataset_id, 'train') +test_base_path = os.path.join(dataset_id, 'test') + +# Create directories and generate dummy GeoTIFF files for train dataset +create_directories(train_base_path, [3, 8]) +generate_geotiff_files(train_base_path, [3, 8], profile, Z) +generate_geojson_files(train_base_path, geojson) + +# Create directories and generate dummy GeoTIFF files for test dataset (only 3band and 8band) +create_directories(test_base_path, [3, 8]) +generate_geotiff_files(test_base_path, [3, 8], profile, Z) + +# Create tarballs for train and test datasets +tarball_specs = { + 'train': { + '3band': 'SN1_buildings_train_AOI_1_Rio_3band', + '8band': 'SN1_buildings_train_AOI_1_Rio_8band', + 'geojson': 'SN1_buildings_train_AOI_1_Rio_geojson_buildings', + }, + 'test': { + '3band': 'SN1_buildings_test_AOI_1_Rio_3band', + '8band': 'SN1_buildings_test_AOI_1_Rio_8band', + }, +} + +for split, specs in tarball_specs.items(): + for subdir, tarball_name in specs.items(): + tarball_path = os.path.join(dataset_id, split, tarball_name) + shutil.make_archive( + tarball_path, + 'gztar', + root_dir=os.path.join(dataset_id, split), + base_dir=subdir, + ) + +# Compute and print MD5 checksums for the generated tarballs +print('MD5 Checksums for Train Dataset:') +train_tarballs = [ + 'SN1_buildings_train_AOI_1_Rio_3band.tar.gz', + 'SN1_buildings_train_AOI_1_Rio_8band.tar.gz', + 'SN1_buildings_train_AOI_1_Rio_geojson_buildings.tar.gz', +] +for tarball in train_tarballs: + tarball_path = os.path.join(dataset_id, 'train', tarball) + if os.path.exists(tarball_path): + print(f'{tarball}: {compute_md5(tarball_path)}') + +print('\nMD5 Checksums for Test Dataset:') +test_tarballs = [ + 'SN1_buildings_test_AOI_1_Rio_3band.tar.gz', + 'SN1_buildings_test_AOI_1_Rio_8band.tar.gz', +] +for tarball in test_tarballs: + tarball_path = os.path.join(dataset_id, 'test', tarball) + if os.path.exists(tarball_path): + print(f'{tarball}: {compute_md5(tarball_path)}') diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/test/SN6_buildings_AOI_11_Rotterdam_test.tar.gz b/tests/data/spacenet/spacenet6/SN6_buildings/test/SN6_buildings_AOI_11_Rotterdam_test.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..d787b796d94a8301c797f24e77b124e17d48115d GIT binary patch literal 714 zcmV;*0yX^~iwFn;;~i%L|5HvjUt)D>Y-DL}XLDacPf1@fF<(+|baZ8MWMOSzbY*jN zE_7jX0PU8|YZE~j#%Ghz#u}snKQ0Oj-UO4Go!Q-ZXh}{n7cEIa50xdgD=s9lBvYv( z2vvv_@g$x-h!;g$@DGvV$(uqw^ybC0Guu_Sg<7I*s@>Gz~JzcAYht{3-f4c*kPYwO5do5$nNo@c_PE_axqmg;|t2~JFVnEl@g zTD{-Z?RNY>r2zeh{%_ZR)qW+;q5lcf|H|c>$Cy{YC8gh;YqpDf*#Cp+zfDy+^dI^U z{fGX8gVO&-rGCEFk$$Ha$UDWq>i@y?-?ga&{ZESiTQ-IM9}ueH%=xCgIWd3`G%h*b zv@V|t%f0R8-j;IDqRLfDR4~RYOT>4D%{>{ke2*1maAOQ!^iS*mAAfe;)Q%%|)PILt zTlJqa<}zZ^VfKGQ^}kj-N3tsB2{F>dP+3Y1BbKLBo>B3m8tG_WkC9kS-pGXcvidm@ z&Fgbc#%fMQHREcWj$Nl7t7$}QeOBYxgB(e#xS__ w6X*W|{ty3$|HJ>`|3mhF00000000000000000000004)B?~>f6R{&4|0Abp6)&Kwi literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif b/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif b/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif b/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif b/tests/data/spacenet/spacenet6/SN6_buildings/test/test_public/AOI_11_Rotterdam/SAR-Intensity/SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/SN6_buildings_AOI_11_Rotterdam_train.tar.gz b/tests/data/spacenet/spacenet6/SN6_buildings/train/SN6_buildings_AOI_11_Rotterdam_train.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..a863cfbe026fdca74ddf37e481e32d0a4b569a21 GIT binary patch literal 1665 zcmYjRe^`?D7B^jKdd-rGnK_)TTGnKS%&X0qR&!}e*-fuM@YTeWOx;MOhV8AXqg9sH zoOflByERQsOD!^gyrXnxRG?VRM-j>&R8CO@1%dZmvb(jv&h!1A^E{tl=Q*U~Ha3<6 zE=iWKGxQT=cP48ela-dVAMvMeMLa!`u=I?KL^d-%70F=7v(h{=;@K9X=S3;bfy>(? zZf=cvyx6&Gs_WbB>1~C>HyUrc3LVNTjwf7_EM2~W$sMhD5g$I{SVsM>Ug5Znep&fm z5Sf~4Y1$Ap-$(l-fPL?(pQf*;XkX1ok+ttdMxIsCtCBvY7z#K_LnjfkmK<+?zF*W} zAVoFUi=M=8E!Z3LFULD=ELmz-h*Ghz}C-*N3{F^ zuBm8(|Zaf&|@+X=rs!rs}q=XHpi~b3So%>^jQk z?Lkfi9LalB7uph+$a>I`9!0!(oe<^U z*&x3l=V~TJR~nGhsNby#WbfE5zd@IWnX0%=?DW#>QN6dKTmJKpe45X#G2FgMjvZ3n zm}s|7gOS)PEcxQ|D!HjMOW-{%mC=W3p?lmY&x1!lY(j1D98k~#=HPW6I7WfK|(MG|nFsJ{Y7*z_og;TntzBMm}Q_9q3;>*j(L2 z{M6T$ch_Jr@OXzbxn{nk#o(l?af8S}W7(hd;o3Mq2i(lrmHrYA$V@a}9@uq52vv(FQ0Y(ZgP&TDUAHsJ2YsM;D!-$9 zN-GfCwP+3s3nf>G%#Gw^LzChzC3gIG`vtkA4Exd%8%FTE1*_iyA;js$zrM}I7;zGo z|39PIGNdE_t*u86o%~G>B4PXuy}WUde6>!AI^Bb?c6f&KaXq$l8tSv=_;na9zpB23 zPY>5~6tImThQp8pR%Wo$XEZC=HAovd3I}lOH_3zKt#w8qz5z#*U*j&(lYO7lTENNt zS)`z;u^D1MYhTbZJITKpc+#-cd*{k__g(5oX-(FXShJCwL$J~#_jTCkGY&vJ0cR|d zhvAW}KY{k;o;X2IoI+gG1s-&6FHVo0AHXwndc*43pqbU%P zJ0TB#y)$u9G=x6BY47k)n;Cf(;`{#nUu6}&Oo&wOt7CLRd=n8I@!$KgNcUj zjD?RD+)s>-P4y|eonN$M5n*^8wQPlN{=@aZ&;!3XQ570k;qu2NQ#S9LuDg%4B~>dP z)cIv{BN?*ZXxXfFSjenrW>4`=P}GgiG2hj@=D>yU{z9A0q~|C-*lEgQ+`{627KFKb literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_1.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_1.tif new file mode 100644 index 0000000000000000000000000000000000000000..650664c080f6e4f38256f02499bb88d8eff88141 GIT binary patch literal 370 zcmebD)MDUZU|-qGR53%@Aa!g=Y(YjAu--hNgea1@7?ce% zQyi*>1;~~`QWK2C=4<9*UlWP`xdk|_(^uUxW=O)87|c;S*AL=-o<Q{me>)an!iG1^PfT?5z`-Yu? z0q9spplv{>18JZoz(8PRcqYKev9TQ}%fJTa_bGF7Y-k6`bAxFHhK}5lX|hX-K;}6t U3yE+HcMn#uFsWf!!&Tn{0QhPumjD0& literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_2.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_2.tif new file mode 100644 index 0000000000000000000000000000000000000000..650664c080f6e4f38256f02499bb88d8eff88141 GIT binary patch literal 370 zcmebD)MDUZU|-qGR53%@Aa!g=Y(YjAu--hNgea1@7?ce% zQyi*>1;~~`QWK2C=4<9*UlWP`xdk|_(^uUxW=O)87|c;S*AL=-o<Q{me>)an!iG1^PfT?5z`-Yu? z0q9spplv{>18JZoz(8PRcqYKev9TQ}%fJTa_bGF7Y-k6`bAxFHhK}5lX|hX-K;}6t U3yE+HcMn#uFsWf!!&Tn{0QhPumjD0& literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_3.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_3.tif new file mode 100644 index 0000000000000000000000000000000000000000..650664c080f6e4f38256f02499bb88d8eff88141 GIT binary patch literal 370 zcmebD)MDUZU|-qGR53%@Aa!g=Y(YjAu--hNgea1@7?ce% zQyi*>1;~~`QWK2C=4<9*UlWP`xdk|_(^uUxW=O)87|c;S*AL=-o<Q{me>)an!iG1^PfT?5z`-Yu? z0q9spplv{>18JZoz(8PRcqYKev9TQ}%fJTa_bGF7Y-k6`bAxFHhK}5lX|hX-K;}6t U3yE+HcMn#uFsWf!!&Tn{0QhPumjD0& literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_4.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PAN/SN6_Train_AOI_11_Rotterdam_PAN_20190804111224_20190804111453_tile_4.tif new file mode 100644 index 0000000000000000000000000000000000000000..650664c080f6e4f38256f02499bb88d8eff88141 GIT binary patch literal 370 zcmebD)MDUZU|-qGR53%@Aa!g=Y(YjAu--hNgea1@7?ce% zQyi*>1;~~`QWK2C=4<9*UlWP`xdk|_(^uUxW=O)87|c;S*AL=-o<Q{me>)an!iG1^PfT?5z`-Yu? z0q9spplv{>18JZoz(8PRcqYKev9TQ}%fJTa_bGF7Y-k6`bAxFHhK}5lX|hX-K;}6t U3yE+HcMn#uFsWf!!&Tn{0QhPumjD0& literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_1.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGB/SN6_Train_AOI_11_Rotterdam_PS-RGB_20190804111224_20190804111453_tile_1.tif new file mode 100644 index 0000000000000000000000000000000000000000..96950caa28902b7f9d2cd088eaaf647e9090ba8a GIT binary patch literal 390 zcmebD)MDUZU|-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cN8q>A&XsONv0|IV=l_a13`3R-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cN8q>A&XsONv0|IV=l_a13`3R-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cN8q>A&XsONv0|IV=l_a13`3R-mK1I5k(F*8&gq>c?qjUXcnSZ@_jLKG?v z(j$hXMjWb!2PiIsWKJ-U4N`jri20g%!0cN8q>A&XsONv0|IV=l_a13`3R-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_2.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_2.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_3.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_3.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_4.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/PS-RGBNIR/SN6_Train_AOI_11_Rotterdam_PS-RGBNIR_20190804111224_20190804111453_tile_4.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_1.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_1.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_2.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_2.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_3.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_3.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_4.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/RGBNIR/SN6_Train_AOI_11_Rotterdam_RGBNIR_20190804111224_20190804111453_tile_4.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_1.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_2.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_3.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/SAR-Intensity/SN6_Train_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_4.tif new file mode 100644 index 0000000000000000000000000000000000000000..cce10b4555ad7ef8a9a07c1bda627a1d8971291a GIT binary patch literal 410 zcmebD)MDUZU|-n#0L5+rF*8&gq>c?qjUXcnSZ^0lLKG?v z(j$hXMjWa}04OelWKIy0nqVLsr0)?B^ELA@FazmVK-|>A!@vflnSkc6Z)avu0J4pM z><#TaVD}aQ*&ExLz&>dLvO$0Y3K@Ye1Hq>yQx>>ixnvicR2K8`!X-P1D%|9jr!ift zUkN&_bAMPR^3Br$rV?Zp0|Pq)$f1lt+kxH!n-8*_k>QyDBge*epezF$nBS+&$+4jw rq=y?!Gca`ImQ0gfQUo&3VOdCoW4L>;f`v&9!x|vq0)l!V=m7!%H`p=C literal 0 HcmV?d00001 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_1.geojson b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_1.geojson new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_2.geojson b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_2.geojson new file mode 100644 index 0000000000..7ae5755f9f --- /dev/null +++ b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_2.geojson @@ -0,0 +1 @@ +{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[4.47917, 51.9225, 0.0], [4.4792, 51.92255, 0.0], [4.47925, 51.92252, 0.0], [4.47922, 51.92247, 0.0], [4.47917, 51.9225, 0.0]]]}}]} \ No newline at end of file diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_3.geojson b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_3.geojson new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_4.geojson b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_4.geojson new file mode 100644 index 0000000000..7ae5755f9f --- /dev/null +++ b/tests/data/spacenet/spacenet6/SN6_buildings/train/train/AOI_11_Rotterdam/geojson_buildings/SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_4.geojson @@ -0,0 +1 @@ +{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[4.47917, 51.9225, 0.0], [4.4792, 51.92255, 0.0], [4.47925, 51.92252, 0.0], [4.47922, 51.92247, 0.0], [4.47917, 51.9225, 0.0]]]}}]} \ No newline at end of file diff --git a/tests/data/spacenet/spacenet6/data.py b/tests/data/spacenet/spacenet6/data.py new file mode 100644 index 0000000000..47f2b59510 --- /dev/null +++ b/tests/data/spacenet/spacenet6/data.py @@ -0,0 +1,171 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import hashlib +import json +import os +import shutil +from typing import Any + +import numpy as np +import rasterio +from rasterio.crs import CRS +from rasterio.transform import Affine + +SIZE = 2 + +NUM_SAMPLES = 4 + +dataset_id = 'SN6_buildings' + +profile = { + 'driver': 'GTiff', + 'dtype': 'uint8', + 'width': SIZE, + 'height': SIZE, + 'crs': CRS.from_epsg(4326), + 'transform': Affine( + 4.489235388119662e-06, 0.0, 4.47917, 0.0, -4.486127586210932e-06, 51.9225 + ), +} + +np.random.seed(0) +Z = np.random.randint(np.iinfo('uint8').max, size=(SIZE, SIZE), dtype='uint8') + +# Define the types of imagery for SpaceNet6 +imagery_types = ['PAN', 'PS-RGB', 'PS-RGBNIR', 'RGBNIR', 'SAR-Intensity'] +imagery_channels = { + 'PAN': 1, + 'PS-RGB': 3, + 'PS-RGBNIR': 4, + 'RGBNIR': 4, + 'SAR-Intensity': 4, +} + + +def create_directories(base_path: str, imagery_types: list[str]) -> None: + for imagery_type in imagery_types: + os.makedirs(os.path.join(base_path, imagery_type), exist_ok=True) + + +def generate_geotiff_files( + base_path: str, + imagery_types: str, + imagery_channels: int, + profile: dict[str, Any], + Z: np.ndarray, + test: bool = False, +) -> None: + for imagery_type in imagery_types: + for i in range(1, NUM_SAMPLES + 1): + if test and imagery_type == 'SAR-Intensity': + path = os.path.join( + base_path, + f'SN6_Test_Public_AOI_11_Rotterdam_SAR-Intensity_20190804111224_20190804111453_tile_{i}.tif', + ) + else: + path = os.path.join( + base_path, + imagery_type, + f'SN6_Train_AOI_11_Rotterdam_{imagery_type}_20190804111224_20190804111453_tile_{i}.tif', + ) + profile['count'] = imagery_channels[imagery_type] + with rasterio.open(path, 'w', **profile) as src: + for j in range(1, profile['count'] + 1): + src.write(Z, j) + + +def generate_geojson_files(base_path: str, geojson: dict[str, Any]) -> None: + os.makedirs(os.path.join(base_path, 'geojson_buildings'), exist_ok=True) + for i in range(1, NUM_SAMPLES + 1): + path = os.path.join( + base_path, + 'geojson_buildings', + f'SN6_Train_AOI_11_Rotterdam_Buildings_20190804111224_20190804111453_tile_{i}.geojson', + ) + with open(path, 'w') as src: + if i % 2 == 0: + json.dump(geojson, src) + + +def compute_md5(file_path: str) -> str: + hash_md5 = hashlib.md5() + with open(file_path, 'rb') as f: + for chunk in iter(lambda: f.read(4096), b''): + hash_md5.update(chunk) + return hash_md5.hexdigest() + + +# Generate dummy GeoJSON files for building footprints +geojson = { + 'type': 'FeatureCollection', + 'crs': {'type': 'name', 'properties': {'name': 'urn:ogc:def:crs:OGC:1.3:CRS84'}}, + 'features': [ + { + 'type': 'Feature', + 'geometry': { + 'type': 'Polygon', + 'coordinates': [ + [ + [4.47917, 51.9225, 0.0], + [4.47920, 51.92255, 0.0], + [4.47925, 51.92252, 0.0], + [4.47922, 51.92247, 0.0], + [4.47917, 51.9225, 0.0], + ] + ], + }, + } + ], +} + +# Remove existing data if it exists +if os.path.exists(dataset_id): + shutil.rmtree(dataset_id) + +train_base_path = os.path.join(dataset_id, 'train/train/AOI_11_Rotterdam') +test_base_path = os.path.join( + dataset_id, 'test/test_public/AOI_11_Rotterdam/SAR-Intensity' +) + +# Create directories and generate dummy GeoTIFF files for train dataset +create_directories(train_base_path, imagery_types) +generate_geotiff_files(train_base_path, imagery_types, imagery_channels, profile, Z) +generate_geojson_files(train_base_path, geojson) + +# Create directories and generate dummy GeoTIFF files for test dataset (only SAR-Intensity) +os.makedirs(test_base_path, exist_ok=True) +generate_geotiff_files( + test_base_path, ['SAR-Intensity'], imagery_channels, profile, Z, test=True +) + +# Create tarballs for train and test datasets +shutil.make_archive( + os.path.join(dataset_id, 'train', 'SN6_buildings_AOI_11_Rotterdam_train'), + 'gztar', + root_dir=os.path.join(dataset_id, 'train'), + base_dir='train', +) +shutil.make_archive( + os.path.join(dataset_id, 'test', 'SN6_buildings_AOI_11_Rotterdam_test'), + 'gztar', + root_dir=os.path.join(dataset_id, 'test'), + base_dir='test_public', +) + +# Compute and print MD5 checksums for the generated tarballs +print('MD5 Checksums for Train Dataset:') +train_tarball_path = os.path.join( + dataset_id, 'train', 'SN6_buildings_AOI_11_Rotterdam_train.tar.gz' +) +if os.path.exists(train_tarball_path): + print(f'Train: {compute_md5(train_tarball_path)}') + +print('\nMD5 Checksums for Test Dataset:') +test_tarball_path = os.path.join( + dataset_id, 'test', 'SN6_buildings_AOI_11_Rotterdam_test.tar.gz' +) +if os.path.exists(test_tarball_path): + print(f'Test: {compute_md5(test_tarball_path)}') diff --git a/tests/datasets/test_spacenet.py b/tests/datasets/test_spacenet.py index 4385e7eee0..36d0d57c24 100644 --- a/tests/datasets/test_spacenet.py +++ b/tests/datasets/test_spacenet.py @@ -9,48 +9,70 @@ import pytest import torch import torch.nn as nn +from _pytest.fixtures import SubRequest from pytest import MonkeyPatch -from torchgeo.datasets import DatasetNotFoundError, SpaceNet1 +from torchgeo.datasets import DatasetNotFoundError, SpaceNet, SpaceNet1, SpaceNet6 from torchgeo.datasets.utils import Executable class TestSpaceNet: - @pytest.fixture + @pytest.fixture(params=[SpaceNet1, SpaceNet6]) def dataset( - self, aws: Executable, monkeypatch: MonkeyPatch, tmp_path: Path - ) -> SpaceNet1: + self, + request: SubRequest, + aws: Executable, + monkeypatch: MonkeyPatch, + tmp_path: Path, + ) -> SpaceNet: + dataset_class: type[SpaceNet] = request.param url = os.path.join( - 'tests', 'data', 'spacenet', '{dataset_id}', 'train', '{tarball}' + 'tests', + 'data', + 'spacenet', + dataset_class.__name__.lower(), + '{dataset_id}', + 'train', + '{tarball}', ) - monkeypatch.setattr(SpaceNet1, 'url', url) + monkeypatch.setattr(dataset_class, 'url', url) transforms = nn.Identity() - return SpaceNet1(tmp_path, transforms=transforms, download=True) + return dataset_class(tmp_path, transforms=transforms, download=True) @pytest.mark.parametrize('index', [0, 1]) - def test_getitem(self, dataset: SpaceNet1, index: int) -> None: + def test_getitem(self, dataset: SpaceNet, index: int) -> None: x = dataset[index] assert isinstance(x, dict) assert isinstance(x['image'], torch.Tensor) assert isinstance(x['mask'], torch.Tensor) - def test_len(self, dataset: SpaceNet1) -> None: - assert len(dataset) == 3 + def test_len(self, dataset: SpaceNet) -> None: + assert len(dataset) == 4 - def test_already_extracted(self, dataset: SpaceNet1) -> None: - SpaceNet1(root=dataset.root) + def test_already_extracted(self, dataset: SpaceNet) -> None: + dataset.__class__(root=dataset.root) - def test_already_downloaded(self, dataset: SpaceNet1) -> None: - for product in ['3band', '8band', 'geojson']: - dir = os.path.join(dataset.root, dataset.dataset_id, dataset.split, product) + def test_already_downloaded(self, dataset: SpaceNet) -> None: + if dataset.dataset_id == 'SN1_buildings': + base_dir = os.path.join(dataset.root, dataset.dataset_id, dataset.split) + elif dataset.dataset_id == 'SN6_buildings': + base_dir = os.path.join( + dataset.root, + dataset.dataset_id, + dataset.split, + dataset.split, + 'AOI_11_Rotterdam', + ) + for product in dataset.valid_images['train'] + list(dataset.valid_masks): + dir = os.path.join(base_dir, product) shutil.rmtree(dir) - SpaceNet1(root=dataset.root) + dataset.__class__(root=dataset.root) - def test_not_downloaded(self, tmp_path: Path) -> None: + def test_not_downloaded(self, tmp_path: Path, dataset: SpaceNet) -> None: with pytest.raises(DatasetNotFoundError, match='Dataset not found'): - SpaceNet1(tmp_path) + dataset.__class__(root=os.path.join(tmp_path, 'dummy')) - def test_plot(self, dataset: SpaceNet1) -> None: + def test_plot(self, dataset: SpaceNet) -> None: x = dataset[0] dataset.plot(x, show_titles=False) plt.close() @@ -58,12 +80,12 @@ def test_plot(self, dataset: SpaceNet1) -> None: dataset.plot(x, suptitle='Test') plt.close() - def test_image_id(self, monkeypatch: MonkeyPatch, dataset: SpaceNet1) -> None: + def test_image_id(self, monkeypatch: MonkeyPatch, dataset: SpaceNet) -> None: file_regex = r'global_monthly_(\d+.*\d+)' monkeypatch.setattr(dataset, 'file_regex', file_regex) dataset._image_id('global_monthly_2018_01_mosaic_L15-0331E-1257N_1327_3160.tif') - def test_list_files(self, monkeypatch: MonkeyPatch, dataset: SpaceNet1) -> None: + def test_list_files(self, monkeypatch: MonkeyPatch, dataset: SpaceNet) -> None: directory_glob = os.path.join('**', 'AOI_{aoi}_*', '{product}') monkeypatch.setattr(dataset, 'directory_glob', directory_glob) dataset._list_files(aoi=1) diff --git a/tests/trainers/test_segmentation.py b/tests/trainers/test_segmentation.py index 8c33fa702f..4bdd966a1b 100644 --- a/tests/trainers/test_segmentation.py +++ b/tests/trainers/test_segmentation.py @@ -77,6 +77,7 @@ class TestSemanticSegmentationTask: 'sentinel2_south_america_soybean', 'southafricacroptype', 'spacenet1', + 'spacenet6', 'ssl4eo_l_benchmark_cdl', 'ssl4eo_l_benchmark_nlcd', 'vaihingen2d', diff --git a/torchgeo/datamodules/__init__.py b/torchgeo/datamodules/__init__.py index 3bbb5153b4..ae4f029c93 100644 --- a/torchgeo/datamodules/__init__.py +++ b/torchgeo/datamodules/__init__.py @@ -43,7 +43,7 @@ from .skippd import SKIPPDDataModule from .so2sat import So2SatDataModule from .southafricacroptype import SouthAfricaCropTypeDataModule -from .spacenet import SpaceNet1DataModule +from .spacenet import SpaceNet1DataModule, SpaceNet6DataModule, SpaceNetBaseDataModule from .ssl4eo import SSL4EOLDataModule, SSL4EOS12DataModule from .ssl4eo_benchmark import SSL4EOLBenchmarkDataModule from .sustainbench_crop_yield import SustainBenchCropYieldDataModule @@ -99,7 +99,9 @@ 'SEN12MSDataModule', 'SKIPPDDataModule', 'So2SatDataModule', + 'SpaceNetBaseDataModule', 'SpaceNet1DataModule', + 'SpaceNet6DataModule', 'SSL4EOLBenchmarkDataModule', 'SSL4EOLDataModule', 'SSL4EOS12DataModule', diff --git a/torchgeo/datamodules/spacenet.py b/torchgeo/datamodules/spacenet.py index dad903bd71..e6b0b32582 100644 --- a/torchgeo/datamodules/spacenet.py +++ b/torchgeo/datamodules/spacenet.py @@ -10,57 +10,44 @@ from torch import Tensor from torch.utils.data import random_split -from ..datasets import SpaceNet1 +from ..datasets import SpaceNet, SpaceNet1, SpaceNet6 from ..transforms import AugmentationSequential from .geo import NonGeoDataModule -class SpaceNet1DataModule(NonGeoDataModule): - """LightningDataModule implementation for the SpaceNet1 dataset. +class SpaceNetBaseDataModule(NonGeoDataModule): + """LightningDataModule implementation for the SpaceNet datasets. - Randomly splits into train/val/test. + Randomly splits the train split into train/val/test. The test split does not have labels, + and is only used for prediction. - .. versionadded:: 0.4 + .. versionadded:: 0.7 """ def __init__( self, + spacenet_ds_class: type[SpaceNet], batch_size: int = 64, num_workers: int = 0, val_split_pct: float = 0.1, test_split_pct: float = 0.2, **kwargs: Any, ) -> None: - """Initialize a new SpaceNet1DataModule instance. + """Initialize a new SpaceNetBaseDataModule instance. Args: + spacenet_ds_class: The SpaceNet dataset class to use. batch_size: Size of each mini-batch. - num_workers: Number of workers for parallel data loading. val_split_pct: Percentage of the dataset to use as a validation set. test_split_pct: Percentage of the dataset to use as a test set. - **kwargs: Additional keyword arguments passed to - :class:`~torchgeo.datasets.SpaceNet1`. + num_workers: Number of workers for parallel data loading. + **kwargs: Additional keyword arguments passed to the SpaceNet dataset. """ - super().__init__(SpaceNet1, batch_size, num_workers, **kwargs) + super().__init__(spacenet_ds_class, batch_size, num_workers, **kwargs) self.val_split_pct = val_split_pct self.test_split_pct = test_split_pct - - self.train_aug = AugmentationSequential( - K.Normalize(mean=self.mean, std=self.std), - K.PadTo((448, 448)), - K.RandomRotation(p=0.5, degrees=90), - K.RandomHorizontalFlip(p=0.5), - K.RandomVerticalFlip(p=0.5), - K.RandomSharpness(p=0.5), - K.ColorJitter(p=0.5, brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1), - data_keys=['image', 'mask'], - ) - self.aug = AugmentationSequential( - K.Normalize(mean=self.mean, std=self.std), - K.PadTo((448, 448)), - data_keys=['image', 'mask'], - ) + self.spacenet_ds_class = spacenet_ds_class def setup(self, stage: str) -> None: """Set up datasets. @@ -68,17 +55,22 @@ def setup(self, stage: str) -> None: Args: stage: Either 'fit', 'validate', 'test', or 'predict'. """ - self.dataset = SpaceNet1(**self.kwargs) - generator = torch.Generator().manual_seed(0) - self.train_dataset, self.val_dataset, self.test_dataset = random_split( - self.dataset, - [ - 1 - self.val_split_pct - self.test_split_pct, - self.val_split_pct, - self.test_split_pct, - ], - generator, - ) + if stage in ['fit', 'validate', 'test']: + self.dataset = self.spacenet_ds_class(split='train', **self.kwargs) + generator = torch.Generator().manual_seed(0) + self.train_dataset, self.val_dataset, self.test_dataset = random_split( + self.dataset, + [ + 1 - self.val_split_pct - self.test_split_pct, + self.val_split_pct, + self.test_split_pct, + ], + generator, + ) + + # test split in SpaceNet does not have labels + if stage in ['predict']: + self.predict_dataset = self.spacenet_ds_class(split='test', **self.kwargs) def on_after_batch_transfer( self, batch: dict[str, Tensor], dataloader_idx: int @@ -95,6 +87,93 @@ def on_after_batch_transfer( # We add 1 to the mask to map the current {background, building} labels to # the values {1, 2}. This is necessary because we add 0 padding to the # mask that we want to ignore in the loss function. - batch['mask'] += 1 + if 'mask' in batch: + batch['mask'] += 1 return super().on_after_batch_transfer(batch, dataloader_idx) + + +class SpaceNet1DataModule(SpaceNetBaseDataModule): + """LightningDataModule implementation for the SpaceNet1 dataset. + + Randomly splits the train split into train/val/test. The test split does not have labels, + and is only used for prediction. + + .. versionadded:: 0.4 + """ + + def __init__( + self, + batch_size: int = 64, + num_workers: int = 0, + val_split_pct: float = 0.1, + test_split_pct: float = 0.2, + **kwargs: Any, + ) -> None: + """Initialize a new SpaceNet1DataModule instance. + + Args: + batch_size: Size of each mini-batch. + num_workers: Number of workers for parallel data loading. + val_split_pct: Percentage of the dataset to use as a validation set. + test_split_pct: Percentage of the dataset to use as a test set. + **kwargs: Additional keyword arguments passed to + :class:`~torchgeo.datasets.SpaceNet1`. + """ + super().__init__( + SpaceNet1, batch_size, num_workers, val_split_pct, test_split_pct, **kwargs + ) + + self.train_aug = AugmentationSequential( + K.Normalize(mean=self.mean, std=self.std), + K.PadTo((448, 448)), + K.RandomRotation(p=0.5, degrees=90), + K.RandomHorizontalFlip(p=0.5), + K.RandomVerticalFlip(p=0.5), + K.RandomSharpness(p=0.5), + K.ColorJitter(p=0.5, brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1), + data_keys=['image', 'mask'], + ) + self.aug = AugmentationSequential( + K.Normalize(mean=self.mean, std=self.std), + K.PadTo((448, 448)), + data_keys=['image', 'mask'], + ) + + self.predict_aug = AugmentationSequential( + K.Normalize(mean=self.mean, std=self.std), + K.PadTo((448, 448)), + data_keys=['image'], + ) + + +class SpaceNet6DataModule(SpaceNetBaseDataModule): + """LightningDataModule implementation for the SpaceNet6 dataset. + + Randomly splits the train split into train/val/test. The test split does not have labels, + and is only used for prediction. + + .. versionadded:: 0.7 + """ + + def __init__( + self, + batch_size: int = 64, + num_workers: int = 0, + val_split_pct: float = 0.1, + test_split_pct: float = 0.2, + **kwargs: Any, + ) -> None: + """Initialize a new SpaceNet6DataModule instance. + + Args: + batch_size: Size of each mini-batch. + num_workers: Number of workers for parallel data loading. + val_split_pct: Percentage of the dataset to use as a validation set. + test_split_pct: Percentage of the dataset to use as a test set. + **kwargs: Additional keyword arguments passed to + :class:`~torchgeo.datasets.SpaceNet6`. + """ + super().__init__( + SpaceNet6, batch_size, num_workers, val_split_pct, test_split_pct, **kwargs + )