diff --git a/conf/defaults.yaml b/conf/defaults.yaml index ca50a41571e..1ccc0c9168f 100644 --- a/conf/defaults.yaml +++ b/conf/defaults.yaml @@ -1,7 +1,7 @@ config_file: null # This lets the user pass a config filename to load other arguments from program: # These are the arguments that define how the train.py script works - seed: 1337 + seed: 0 output_dir: output data_dir: data log_dir: logs @@ -16,16 +16,17 @@ experiment: # These are arugments specific to the experiment we are running root_dir: ${program.data_dir} seed: ${program.seed} batch_size: 32 - num_workers: 4 + num_workers: 0 # The values here are taken from the defaults here https://pytorch-lightning.readthedocs.io/en/1.3.8/common/trainer.html#init # this probably should be made into a schema, e.g. as shown https://omegaconf.readthedocs.io/en/2.0_branch/structured_config.html#merging-with-other-configs trainer: # These are the parameters passed to the pytorch lightning Trainer object logger: True - checkpoint_callback: True callbacks: null default_root_dir: null + detect_anomaly: False + enable_checkpointing: True gradient_clip_val: 0.0 gradient_clip_algorithm: 'norm' process_position: 0 @@ -43,7 +44,7 @@ trainer: # These are the parameters passed to the pytorch lightning Trainer obje accumulate_grad_batches: 1 max_epochs: null min_epochs: null - max_steps: null + max_steps: -1 min_steps: null max_time: null limit_train_batches: 1.0 @@ -51,8 +52,7 @@ trainer: # These are the parameters passed to the pytorch lightning Trainer obje limit_test_batches: 1.0 limit_predict_batches: 1.0 val_check_interval: 1.0 - flush_logs_every_n_steps: 100 - log_every_n_steps: 50 + log_every_n_steps: 1 accelerator: null sync_batchnorm: False precision: 32 @@ -66,9 +66,7 @@ trainer: # These are the parameters passed to the pytorch lightning Trainer obje reload_dataloaders_every_epoch: False auto_lr_find: False replace_sampler_ddp: True - terminate_on_nan: False auto_scale_batch_size: False - prepare_data_per_node: True plugins: null amp_backend: 'native' move_metrics_to_cpu: False diff --git a/conf/task_defaults/bigearthnet.yaml b/conf/task_defaults/bigearthnet_all.yaml similarity index 94% rename from conf/task_defaults/bigearthnet.yaml rename to conf/task_defaults/bigearthnet_all.yaml index c5c352861ba..ba55f85e709 100644 --- a/conf/task_defaults/bigearthnet.yaml +++ b/conf/task_defaults/bigearthnet_all.yaml @@ -12,5 +12,5 @@ experiment: root_dir: "tests/data/bigearthnet" bands: "all" num_classes: ${experiment.module.num_classes} - batch_size: 128 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/bigearthnet_s1.yaml b/conf/task_defaults/bigearthnet_s1.yaml new file mode 100644 index 00000000000..73e727a04ea --- /dev/null +++ b/conf/task_defaults/bigearthnet_s1.yaml @@ -0,0 +1,16 @@ +experiment: + task: "bigearthnet" + module: + loss: "bce" + classification_model: "resnet18" + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + weights: "random" + in_channels: 2 + num_classes: 19 + datamodule: + root_dir: "tests/data/bigearthnet" + bands: "s1" + num_classes: ${experiment.module.num_classes} + batch_size: 1 + num_workers: 0 diff --git a/conf/task_defaults/bigearthnet_s2.yaml b/conf/task_defaults/bigearthnet_s2.yaml new file mode 100644 index 00000000000..9b9983a461d --- /dev/null +++ b/conf/task_defaults/bigearthnet_s2.yaml @@ -0,0 +1,16 @@ +experiment: + task: "bigearthnet" + module: + loss: "bce" + classification_model: "resnet18" + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + weights: "random" + in_channels: 12 + num_classes: 19 + datamodule: + root_dir: "tests/data/bigearthnet" + bands: "s2" + num_classes: ${experiment.module.num_classes} + batch_size: 1 + num_workers: 0 diff --git a/conf/task_defaults/byol.yaml b/conf/task_defaults/byol.yaml index 90eefbc96f6..d79b0def86c 100644 --- a/conf/task_defaults/byol.yaml +++ b/conf/task_defaults/byol.yaml @@ -16,5 +16,5 @@ experiment: - "de-test" test_splits: - "de-test" - batch_size: 64 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/chesapeake_cvpr_5.yaml b/conf/task_defaults/chesapeake_cvpr_5.yaml new file mode 100644 index 00000000000..63b0b469f42 --- /dev/null +++ b/conf/task_defaults/chesapeake_cvpr_5.yaml @@ -0,0 +1,29 @@ +experiment: + task: "chesapeake_cvpr" + module: + loss: "ce" + segmentation_model: "unet" + encoder_name: "resnet50" + encoder_weights: null + encoder_output_stride: 16 + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + in_channels: 4 + num_classes: 5 + num_filters: 1 + ignore_zeros: False + imagenet_pretraining: False + datamodule: + root_dir: "tests/data/chesapeake/cvpr" + train_splits: + - "de-test" + val_splits: + - "de-test" + test_splits: + - "de-test" + patches_per_tile: 2 + patch_size: 64 + batch_size: 2 + num_workers: 0 + class_set: ${experiment.module.num_classes} + use_prior_labels: False diff --git a/conf/task_defaults/chesapeake_cvpr.yaml b/conf/task_defaults/chesapeake_cvpr_7.yaml similarity index 79% rename from conf/task_defaults/chesapeake_cvpr.yaml rename to conf/task_defaults/chesapeake_cvpr_7.yaml index b210d592636..b1cd0bde844 100644 --- a/conf/task_defaults/chesapeake_cvpr.yaml +++ b/conf/task_defaults/chesapeake_cvpr_7.yaml @@ -10,8 +10,9 @@ experiment: learning_rate_schedule_patience: 6 in_channels: 4 num_classes: 7 - num_filters: 256 + num_filters: 1 ignore_zeros: False + imagenet_pretraining: False datamodule: root_dir: "tests/data/chesapeake/cvpr" train_splits: @@ -20,8 +21,9 @@ experiment: - "de-test" test_splits: - "de-test" - patches_per_tile: 200 - patch_size: 256 - batch_size: 64 + patches_per_tile: 2 + patch_size: 64 + batch_size: 2 num_workers: 0 class_set: ${experiment.module.num_classes} + use_prior_labels: False diff --git a/conf/task_defaults/chesapeake_cvpr_prior.yaml b/conf/task_defaults/chesapeake_cvpr_prior.yaml new file mode 100644 index 00000000000..ab7398da3b9 --- /dev/null +++ b/conf/task_defaults/chesapeake_cvpr_prior.yaml @@ -0,0 +1,29 @@ +experiment: + task: "chesapeake_cvpr" + module: + loss: "ce" + segmentation_model: "unet" + encoder_name: "resnet50" + encoder_weights: null + encoder_output_stride: 16 + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + in_channels: 4 + num_classes: 5 + num_filters: 1 + ignore_zeros: False + imagenet_pretraining: False + datamodule: + root_dir: "tests/data/chesapeake/cvpr" + train_splits: + - "de-test" + val_splits: + - "de-test" + test_splits: + - "de-test" + patches_per_tile: 2 + patch_size: 64 + batch_size: 2 + num_workers: 0 + class_set: ${experiment.module.num_classes} + use_prior_labels: True diff --git a/conf/task_defaults/cowc_counting.yaml b/conf/task_defaults/cowc_counting.yaml index a0d43a23462..4a4ab2f9abb 100644 --- a/conf/task_defaults/cowc_counting.yaml +++ b/conf/task_defaults/cowc_counting.yaml @@ -4,7 +4,9 @@ experiment: model: resnet18 learning_rate: 1e-3 learning_rate_schedule_patience: 2 + pretrained: False datamodule: root_dir: "tests/data/cowc_counting" - batch_size: 32 + seed: 0 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/cyclone.yaml b/conf/task_defaults/cyclone.yaml index 3e2fe918094..ba3d039f9d7 100644 --- a/conf/task_defaults/cyclone.yaml +++ b/conf/task_defaults/cyclone.yaml @@ -7,5 +7,6 @@ experiment: pretrained: False datamodule: root_dir: "tests/data/cyclone" - batch_size: 32 + seed: 0 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/etci2021.yaml b/conf/task_defaults/etci2021.yaml index 132887630e2..880ac6232e6 100644 --- a/conf/task_defaults/etci2021.yaml +++ b/conf/task_defaults/etci2021.yaml @@ -12,5 +12,5 @@ experiment: ignore_zeros: True datamodule: root_dir: "tests/data/etci2021" - batch_size: 32 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/eurosat.yaml b/conf/task_defaults/eurosat.yaml index dd40b85f6c9..9161c2c0cae 100644 --- a/conf/task_defaults/eurosat.yaml +++ b/conf/task_defaults/eurosat.yaml @@ -10,5 +10,5 @@ experiment: num_classes: 10 datamodule: root_dir: "tests/data/eurosat" - batch_size: 128 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/landcoverai.yaml b/conf/task_defaults/landcoverai.yaml index 72e2f024999..4e28b018935 100644 --- a/conf/task_defaults/landcoverai.yaml +++ b/conf/task_defaults/landcoverai.yaml @@ -10,9 +10,9 @@ experiment: verbose: false in_channels: 3 num_classes: 6 - num_filters: 256 + num_filters: 1 ignore_zeros: False datamodule: root_dir: "tests/data/landcoverai" - batch_size: 32 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/naipchesapeake.yaml b/conf/task_defaults/naipchesapeake.yaml index e3546ad6ff1..83814f3316a 100644 --- a/conf/task_defaults/naipchesapeake.yaml +++ b/conf/task_defaults/naipchesapeake.yaml @@ -10,11 +10,11 @@ experiment: learning_rate_schedule_patience: 2 in_channels: 4 num_classes: 13 - num_filters: 64 + num_filters: 1 ignore_zeros: False datamodule: naip_root_dir: "tests/data/naip" chesapeake_root_dir: "tests/data/chesapeake/BAYWIDE" - batch_size: 32 + batch_size: 2 num_workers: 0 patch_size: 32 diff --git a/conf/task_defaults/oscd.yaml b/conf/task_defaults/oscd_all.yaml similarity index 74% rename from conf/task_defaults/oscd.yaml rename to conf/task_defaults/oscd_all.yaml index 5ae3fdccb78..9cd70b45daa 100644 --- a/conf/task_defaults/oscd.yaml +++ b/conf/task_defaults/oscd_all.yaml @@ -4,18 +4,18 @@ experiment: loss: "jaccard" segmentation_model: "unet" encoder_name: "resnet18" - encoder_weights: null + encoder_weights: null learning_rate: 1e-3 learning_rate_schedule_patience: 6 verbose: false in_channels: 26 num_classes: 2 - num_filters: 256 + num_filters: 1 ignore_zeros: True datamodule: root_dir: "tests/data/oscd" - batch_size: 32 + batch_size: 1 num_workers: 0 - val_split_pct: 0.1 + val_split_pct: 0.5 bands: "all" - num_patches_per_tile: 128 + num_patches_per_tile: 1 diff --git a/conf/task_defaults/oscd_rgb.yaml b/conf/task_defaults/oscd_rgb.yaml new file mode 100644 index 00000000000..bf24bd4b02a --- /dev/null +++ b/conf/task_defaults/oscd_rgb.yaml @@ -0,0 +1,21 @@ +experiment: + task: "oscd" + module: + loss: "jaccard" + segmentation_model: "unet" + encoder_name: "resnet18" + encoder_weights: null + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + verbose: false + in_channels: 6 + num_classes: 2 + num_filters: 1 + ignore_zeros: True + datamodule: + root_dir: "tests/data/oscd" + batch_size: 1 + num_workers: 0 + val_split_pct: 0.5 + bands: "rgb" + num_patches_per_tile: 1 diff --git a/conf/task_defaults/resisc45.yaml b/conf/task_defaults/resisc45.yaml index a657cc5d02a..e95efe9af89 100644 --- a/conf/task_defaults/resisc45.yaml +++ b/conf/task_defaults/resisc45.yaml @@ -10,5 +10,5 @@ experiment: num_classes: 45 datamodule: root_dir: "tests/data/resisc45" - batch_size: 128 + batch_size: 1 num_workers: 0 diff --git a/conf/task_defaults/sen12ms.yaml b/conf/task_defaults/sen12ms_all.yaml similarity index 87% rename from conf/task_defaults/sen12ms.yaml rename to conf/task_defaults/sen12ms_all.yaml index e4a946a23f8..1a0f73fddd4 100644 --- a/conf/task_defaults/sen12ms.yaml +++ b/conf/task_defaults/sen12ms_all.yaml @@ -13,5 +13,7 @@ experiment: ignore_zeros: False datamodule: root_dir: "tests/data/sen12ms" - batch_size: 32 + band_set: "all" + batch_size: 1 num_workers: 0 + seed: 0 diff --git a/conf/task_defaults/sen12ms_s1.yaml b/conf/task_defaults/sen12ms_s1.yaml new file mode 100644 index 00000000000..a2fdbb17031 --- /dev/null +++ b/conf/task_defaults/sen12ms_s1.yaml @@ -0,0 +1,20 @@ +experiment: + task: "sen12ms" + module: + loss: "focal" + segmentation_model: "fcn" + num_filters: 1 + encoder_name: "resnet18" + encoder_weights: null + encoder_output_stride: 16 + learning_rate: 1e-3 + learning_rate_schedule_patience: 2 + in_channels: 2 + num_classes: 11 + ignore_zeros: False + datamodule: + root_dir: "tests/data/sen12ms" + band_set: "s1" + batch_size: 1 + num_workers: 0 + seed: 0 diff --git a/conf/task_defaults/sen12ms_s2_all.yaml b/conf/task_defaults/sen12ms_s2_all.yaml new file mode 100644 index 00000000000..eb081ef722f --- /dev/null +++ b/conf/task_defaults/sen12ms_s2_all.yaml @@ -0,0 +1,19 @@ +experiment: + task: "sen12ms" + module: + loss: "ce" + segmentation_model: "unet" + encoder_name: "resnet18" + encoder_weights: null + encoder_output_stride: 16 + learning_rate: 1e-3 + learning_rate_schedule_patience: 2 + in_channels: 13 + num_classes: 11 + ignore_zeros: False + datamodule: + root_dir: "tests/data/sen12ms" + band_set: "s2-all" + batch_size: 1 + num_workers: 0 + seed: 0 diff --git a/conf/task_defaults/sen12ms_s2_reduced.yaml b/conf/task_defaults/sen12ms_s2_reduced.yaml new file mode 100644 index 00000000000..e44c20a3dbd --- /dev/null +++ b/conf/task_defaults/sen12ms_s2_reduced.yaml @@ -0,0 +1,19 @@ +experiment: + task: "sen12ms" + module: + loss: "ce" + segmentation_model: "unet" + encoder_name: "resnet18" + encoder_weights: null + encoder_output_stride: 16 + learning_rate: 1e-3 + learning_rate_schedule_patience: 2 + in_channels: 6 + num_classes: 11 + ignore_zeros: False + datamodule: + root_dir: "tests/data/sen12ms" + band_set: "s2-reduced" + batch_size: 1 + num_workers: 0 + seed: 0 diff --git a/conf/task_defaults/so2sat.yaml b/conf/task_defaults/so2sat_supervised.yaml similarity index 81% rename from conf/task_defaults/so2sat.yaml rename to conf/task_defaults/so2sat_supervised.yaml index be6a4e0f5c9..0f215c24c84 100644 --- a/conf/task_defaults/so2sat.yaml +++ b/conf/task_defaults/so2sat_supervised.yaml @@ -1,7 +1,7 @@ experiment: task: "so2sat" module: - loss: "ce" + loss: "focal" classification_model: "resnet18" learning_rate: 1e-3 learning_rate_schedule_patience: 6 @@ -10,6 +10,7 @@ experiment: num_classes: 17 datamodule: root_dir: "tests/data/so2sat" - batch_size: 128 + batch_size: 1 num_workers: 0 bands: "rgb" + unsupervised_mode: False diff --git a/conf/task_defaults/so2sat_unsupervised.yaml b/conf/task_defaults/so2sat_unsupervised.yaml new file mode 100644 index 00000000000..ec51d18c4a6 --- /dev/null +++ b/conf/task_defaults/so2sat_unsupervised.yaml @@ -0,0 +1,16 @@ +experiment: + task: "so2sat" + module: + loss: "jaccard" + classification_model: "resnet18" + learning_rate: 1e-3 + learning_rate_schedule_patience: 6 + weights: "random" + in_channels: 3 + num_classes: 17 + datamodule: + root_dir: "tests/data/so2sat" + batch_size: 1 + num_workers: 0 + bands: "rgb" + unsupervised_mode: True diff --git a/conf/task_defaults/ucmerced.yaml b/conf/task_defaults/ucmerced.yaml index 2742fa329c8..31f7dba2960 100644 --- a/conf/task_defaults/ucmerced.yaml +++ b/conf/task_defaults/ucmerced.yaml @@ -10,5 +10,5 @@ experiment: num_classes: 21 datamodule: root_dir: "tests/data/ucmerced" - batch_size: 128 + batch_size: 1 num_workers: 0 diff --git a/pyproject.toml b/pyproject.toml index 69cca9467a1..6f31702dce8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,10 +79,13 @@ match_dir = "(datamodules|datasets|losses|models|samplers|torchgeo|trainers|tran # Skip slow tests by default addopts = "-m 'not slow'" filterwarnings = [ - "ignore:.*Create unlinked descriptors is going to go away.*:DeprecationWarning", + "ignore:.*Create unlinked descriptors is going to go away:DeprecationWarning", # https://github.com/tensorflow/tensorboard/pull/5138 - "ignore:.*is a deprecated alias for the builtin.*:DeprecationWarning", - "ignore:.*Previous behaviour produces incorrect box coordinates.*:UserWarning", + "ignore:.*is a deprecated alias for the builtin:DeprecationWarning", + "ignore:Previous behaviour produces incorrect box coordinates:UserWarning", + "ignore:The dataloader, .*, does not have many workers which may be a bottleneck:UserWarning", + "ignore:Your `.*_dataloader` has `shuffle=True`:UserWarning", + "ignore:Trying to infer the `batch_size` from an ambiguous collection:UserWarning", ] markers = [ "slow: marks tests as slow", diff --git a/tests/data/README.md b/tests/data/README.md index 3884cbf382a..9e37b4923d4 100644 --- a/tests/data/README.md +++ b/tests/data/README.md @@ -16,7 +16,8 @@ ROOT = "data/landsat8" FILENAME = "LC08_L2SP_023032_20210622_20210629_02_T1_SR_B1.TIF" src = rasterio.open(os.path.join(ROOT, FILENAME)) -Z = np.arange(4, dtype=src.read().dtype).reshape(2, 2) +dtype = src.read().dtype +Z = np.random.randint(np.iinfo(dtype).max, size=(64, 64), dtype=dtype) dst = rasterio.open(FILENAME, "w", driver=src.driver, height=Z.shape[0], width=Z.shape[1], count=src.count, dtype=Z.dtype, crs=src.crs, transform=src.transform) for i in range(1, dst.count + 1): dst.write(Z, i) @@ -52,18 +53,28 @@ VisionDataset data can be created like so. ### RGB images ```python +import numpy as np from PIL import Image -img = Image.new("RGB", (1, 1)) +DTYPE = np.uint8 +SIZE = 64 + +arr = np.random.randint(np.iinfo(DTYPE).max, size=(SIZE, SIZE, 3), dtype=DTYPE) +img = Image.fromarray(arr) img.save("01.png") ``` ### Grayscale images ```python +import numpy as np from PIL import Image -img = Image.new("L", (1, 1)) +DTYPE = np.uint8 +SIZE = 64 + +arr = np.random.randint(np.iinfo(DTYPE).max, size=(SIZE, SIZE), dtype=DTYPE) +img = Image.fromarray(arr) img.save("02.jpg") ``` @@ -83,14 +94,15 @@ wavfile.write("01.wav", rate=22050, data=audio) import h5py import numpy as np -f = h5py.File("data.hdf5", "w") +DTYPE = np.uint8 +SIZE = 64 +NUM_CLASSES = 10 -num_classes = 10 -images = np.random.randint(low=0, high=255, size=(1, 1, 3)).astype(np.uint8) -masks = np.random.randint(low=0, high=num_classes, size=(1, 1)).astype(np.uint8) -f.create_dataset("images", data=images) -f.create_dataset("masks", data=masks) -f.close() +images = np.random.randint(np.iinfo(DTYPE).max, size=(SIZE, SIZE, 3), dtype=DTYPE) +masks = np.random.randint(NUM_CLASSES, size=(SIZE, SIZE), dtype=DTYPE) +with h5py.File("data.hdf5", "w") as f: + f.create_dataset("images", data=images) + f.create_dataset("masks", data=masks) ``` ### LAS Point Cloud files diff --git a/tests/data/cowc_counting/COWC_Counting_Columbus_CSUAV_AFRL.tbz b/tests/data/cowc_counting/COWC_Counting_Columbus_CSUAV_AFRL.tbz index 92dfe682ca0..fc9b54ec201 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Columbus_CSUAV_AFRL.tbz and b/tests/data/cowc_counting/COWC_Counting_Columbus_CSUAV_AFRL.tbz differ diff --git a/tests/data/cowc_counting/COWC_Counting_Potsdam_ISPRS.tbz b/tests/data/cowc_counting/COWC_Counting_Potsdam_ISPRS.tbz index 1a5dd77ed16..29e7d83c121 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Potsdam_ISPRS.tbz and b/tests/data/cowc_counting/COWC_Counting_Potsdam_ISPRS.tbz differ diff --git a/tests/data/cowc_counting/COWC_Counting_Selwyn_LINZ.tbz b/tests/data/cowc_counting/COWC_Counting_Selwyn_LINZ.tbz index 258484e8e2a..9e897ebd2d9 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Selwyn_LINZ.tbz and b/tests/data/cowc_counting/COWC_Counting_Selwyn_LINZ.tbz differ diff --git a/tests/data/cowc_counting/COWC_Counting_Toronto_ISPRS.tbz b/tests/data/cowc_counting/COWC_Counting_Toronto_ISPRS.tbz index c3594d8f5b6..37884f8f77b 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Toronto_ISPRS.tbz and b/tests/data/cowc_counting/COWC_Counting_Toronto_ISPRS.tbz differ diff --git a/tests/data/cowc_counting/COWC_Counting_Utah_AGRC.tbz b/tests/data/cowc_counting/COWC_Counting_Utah_AGRC.tbz index 6eedeae9f68..c425862bf44 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Utah_AGRC.tbz and b/tests/data/cowc_counting/COWC_Counting_Utah_AGRC.tbz differ diff --git a/tests/data/cowc_counting/COWC_Counting_Vaihingen_ISPRS.tbz b/tests/data/cowc_counting/COWC_Counting_Vaihingen_ISPRS.tbz index 27058dd4d92..a1165019fe5 100644 Binary files a/tests/data/cowc_counting/COWC_Counting_Vaihingen_ISPRS.tbz and b/tests/data/cowc_counting/COWC_Counting_Vaihingen_ISPRS.tbz differ diff --git a/tests/data/cowc_counting/COWC_test_list_64_class.txt b/tests/data/cowc_counting/COWC_test_list_64_class.txt index 60ae5328dfd..c46f34bc023 100644 --- a/tests/data/cowc_counting/COWC_test_list_64_class.txt +++ b/tests/data/cowc_counting/COWC_test_list_64_class.txt @@ -1,6 +1,6 @@ -Toronto_ISPRS/test/fake_01.png 0 -Selwyn_LINZ/test/fake_03.png 1 -Potsdam_ISPRS/test/fake_05.png 2 -Vaihingen_ISPRS/test/fake_07.png 0 -Columbus_CSUAV_AFRL/test/fake_09.png 1 -Utah_AGRC/test/fake_11.png 11 +Toronto_ISPRS/test/fake_01.png 12 +Selwyn_LINZ/test/fake_03.png 8 +Potsdam_ISPRS/test/fake_05.png 12 +Vaihingen_ISPRS/test/fake_07.png 11 +Columbus_CSUAV_AFRL/test/fake_09.png 16 +Utah_AGRC/test/fake_11.png 4 diff --git a/tests/data/cowc_counting/COWC_test_list_64_class.txt.bz2 b/tests/data/cowc_counting/COWC_test_list_64_class.txt.bz2 index ac59f5a5a96..95e8e5aed23 100644 Binary files a/tests/data/cowc_counting/COWC_test_list_64_class.txt.bz2 and b/tests/data/cowc_counting/COWC_test_list_64_class.txt.bz2 differ diff --git a/tests/data/cowc_counting/COWC_train_list_64_class.txt b/tests/data/cowc_counting/COWC_train_list_64_class.txt index 60d877ce267..1fb05797843 100644 --- a/tests/data/cowc_counting/COWC_train_list_64_class.txt +++ b/tests/data/cowc_counting/COWC_train_list_64_class.txt @@ -1,12 +1,12 @@ -Toronto_ISPRS/train/fake_01.png 0 -Toronto_ISPRS/train/fake_02.png 3 -Selwyn_LINZ/train/fake_03.png 1 -Selwyn_LINZ/train/fake_04.png 0 -Potsdam_ISPRS/train/fake_05.png 2 -Potsdam_ISPRS/train/fake_06.png 2 -Vaihingen_ISPRS/train/fake_07.png 0 -Vaihingen_ISPRS/train/fake_08.png 0 -Columbus_CSUAV_AFRL/train/fake_09.png 1 -Columbus_CSUAV_AFRL/train/fake_10.png 1 -Utah_AGRC/train/fake_11.png 11 -Utah_AGRC/train/fake_12.png 12 +Toronto_ISPRS/train/fake_01.png 13 +Toronto_ISPRS/train/fake_02.png 1 +Selwyn_LINZ/train/fake_03.png 16 +Selwyn_LINZ/train/fake_04.png 15 +Potsdam_ISPRS/train/fake_05.png 9 +Potsdam_ISPRS/train/fake_06.png 15 +Vaihingen_ISPRS/train/fake_07.png 18 +Vaihingen_ISPRS/train/fake_08.png 6 +Columbus_CSUAV_AFRL/train/fake_09.png 4 +Columbus_CSUAV_AFRL/train/fake_10.png 9 +Utah_AGRC/train/fake_11.png 3 +Utah_AGRC/train/fake_12.png 19 diff --git a/tests/data/cowc_counting/COWC_train_list_64_class.txt.bz2 b/tests/data/cowc_counting/COWC_train_list_64_class.txt.bz2 index 57375a57249..15f5e2f6eb3 100644 Binary files a/tests/data/cowc_counting/COWC_train_list_64_class.txt.bz2 and b/tests/data/cowc_counting/COWC_train_list_64_class.txt.bz2 differ diff --git a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/test/fake_09.png b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/test/fake_09.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/test/fake_09.png and b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/test/fake_09.png differ diff --git a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_09.png b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_09.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_09.png and b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_09.png differ diff --git a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_10.png b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_10.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_10.png and b/tests/data/cowc_counting/Columbus_CSUAV_AFRL/train/fake_10.png differ diff --git a/tests/data/cowc_counting/Potsdam_ISPRS/test/fake_05.png b/tests/data/cowc_counting/Potsdam_ISPRS/test/fake_05.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Potsdam_ISPRS/test/fake_05.png and b/tests/data/cowc_counting/Potsdam_ISPRS/test/fake_05.png differ diff --git a/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_05.png b/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_05.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_05.png and b/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_05.png differ diff --git a/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_06.png b/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_06.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_06.png and b/tests/data/cowc_counting/Potsdam_ISPRS/train/fake_06.png differ diff --git a/tests/data/cowc_counting/Selwyn_LINZ/test/fake_03.png b/tests/data/cowc_counting/Selwyn_LINZ/test/fake_03.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Selwyn_LINZ/test/fake_03.png and b/tests/data/cowc_counting/Selwyn_LINZ/test/fake_03.png differ diff --git a/tests/data/cowc_counting/Selwyn_LINZ/train/fake_03.png b/tests/data/cowc_counting/Selwyn_LINZ/train/fake_03.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Selwyn_LINZ/train/fake_03.png and b/tests/data/cowc_counting/Selwyn_LINZ/train/fake_03.png differ diff --git a/tests/data/cowc_counting/Selwyn_LINZ/train/fake_04.png b/tests/data/cowc_counting/Selwyn_LINZ/train/fake_04.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Selwyn_LINZ/train/fake_04.png and b/tests/data/cowc_counting/Selwyn_LINZ/train/fake_04.png differ diff --git a/tests/data/cowc_counting/Toronto_ISPRS/test/fake_01.png b/tests/data/cowc_counting/Toronto_ISPRS/test/fake_01.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Toronto_ISPRS/test/fake_01.png and b/tests/data/cowc_counting/Toronto_ISPRS/test/fake_01.png differ diff --git a/tests/data/cowc_counting/Toronto_ISPRS/train/fake_01.png b/tests/data/cowc_counting/Toronto_ISPRS/train/fake_01.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Toronto_ISPRS/train/fake_01.png and b/tests/data/cowc_counting/Toronto_ISPRS/train/fake_01.png differ diff --git a/tests/data/cowc_counting/Toronto_ISPRS/train/fake_02.png b/tests/data/cowc_counting/Toronto_ISPRS/train/fake_02.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Toronto_ISPRS/train/fake_02.png and b/tests/data/cowc_counting/Toronto_ISPRS/train/fake_02.png differ diff --git a/tests/data/cowc_counting/Utah_AGRC/test/fake_11.png b/tests/data/cowc_counting/Utah_AGRC/test/fake_11.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Utah_AGRC/test/fake_11.png and b/tests/data/cowc_counting/Utah_AGRC/test/fake_11.png differ diff --git a/tests/data/cowc_counting/Utah_AGRC/train/fake_11.png b/tests/data/cowc_counting/Utah_AGRC/train/fake_11.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Utah_AGRC/train/fake_11.png and b/tests/data/cowc_counting/Utah_AGRC/train/fake_11.png differ diff --git a/tests/data/cowc_counting/Utah_AGRC/train/fake_12.png b/tests/data/cowc_counting/Utah_AGRC/train/fake_12.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Utah_AGRC/train/fake_12.png and b/tests/data/cowc_counting/Utah_AGRC/train/fake_12.png differ diff --git a/tests/data/cowc_counting/Vaihingen_ISPRS/test/fake_07.png b/tests/data/cowc_counting/Vaihingen_ISPRS/test/fake_07.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Vaihingen_ISPRS/test/fake_07.png and b/tests/data/cowc_counting/Vaihingen_ISPRS/test/fake_07.png differ diff --git a/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_07.png b/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_07.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_07.png and b/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_07.png differ diff --git a/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_08.png b/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_08.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_08.png and b/tests/data/cowc_counting/Vaihingen_ISPRS/train/fake_08.png differ diff --git a/tests/data/cowc_counting/data.py b/tests/data/cowc_counting/data.py new file mode 100755 index 00000000000..b75bec2e1e0 --- /dev/null +++ b/tests/data/cowc_counting/data.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import bz2 +import csv +import hashlib +import glob +import os +import random +import shutil + +from PIL import Image + + +SIZE = 64 # image width/height +STOP = 20 # range of values for labels +PREFIX = "Counting" +SUFFIX = "64_class" + +random.seed(0) + +sites = [ + "Toronto_ISPRS", + "Selwyn_LINZ", + "Potsdam_ISPRS", + "Vaihingen_ISPRS", + "Columbus_CSUAV_AFRL", + "Utah_AGRC", +] + +# Remove old data +for filename in glob.glob("COWC_*"): + os.remove(filename) +for site in sites: + if os.path.exists(site): + shutil.rmtree(site) + +i = 1 +data_list = {"train": [], "test": []} +image_md5s = [] +for site in sites: + # Create images + for split in ["test", "train", "train"]: + directory = os.path.join(site, split) + os.makedirs(directory, exist_ok=True) + filename = os.path.join(directory, f"fake_{i:02}.png") + + img = Image.new("RGB", (SIZE, SIZE)) + img.save(filename) + + data_list[split].append((filename, random.randrange(STOP))) + + if split == "train": + i += 1 + + # Compress images + filename = f"COWC_{PREFIX}_{site}.tbz" + bad_filename = shutil.make_archive(filename.replace(".tbz", ""), "bztar", ".", site) + os.rename(bad_filename, filename) + + # Compute checksums + with open(filename, "rb") as f: + image_md5s.append(hashlib.md5(f.read()).hexdigest()) + +label_md5s = [] +for split in ["train", "test"]: + # Create labels + filename = f"COWC_{split}_list_{SUFFIX}.txt" + with open(filename, "w", newline="") as csvfile: + csvwriter = csv.writer(csvfile, delimiter=" ") + csvwriter.writerows(data_list[split]) + + # Compress labels + with open(filename, "rb") as src: + with bz2.open(filename + ".bz2", "wb") as dst: + dst.write(src.read()) + + # Compute checksums + with open(filename + ".bz2", "rb") as f: + label_md5s.append(hashlib.md5(f.read()).hexdigest()) + +md5s = label_md5s + image_md5s +for md5 in md5s: + print(repr(md5) + ",") diff --git a/tests/data/cowc_detection/COWC_Detection_Columbus_CSUAV_AFRL.tbz b/tests/data/cowc_detection/COWC_Detection_Columbus_CSUAV_AFRL.tbz index dff3032bd06..f42c6b4485d 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Columbus_CSUAV_AFRL.tbz and b/tests/data/cowc_detection/COWC_Detection_Columbus_CSUAV_AFRL.tbz differ diff --git a/tests/data/cowc_detection/COWC_Detection_Potsdam_ISPRS.tbz b/tests/data/cowc_detection/COWC_Detection_Potsdam_ISPRS.tbz index ed721194044..c60c8aa418d 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Potsdam_ISPRS.tbz and b/tests/data/cowc_detection/COWC_Detection_Potsdam_ISPRS.tbz differ diff --git a/tests/data/cowc_detection/COWC_Detection_Selwyn_LINZ.tbz b/tests/data/cowc_detection/COWC_Detection_Selwyn_LINZ.tbz index 9be43cea8e8..b3ace699c87 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Selwyn_LINZ.tbz and b/tests/data/cowc_detection/COWC_Detection_Selwyn_LINZ.tbz differ diff --git a/tests/data/cowc_detection/COWC_Detection_Toronto_ISPRS.tbz b/tests/data/cowc_detection/COWC_Detection_Toronto_ISPRS.tbz index 092b9ffd318..1ccc7f304a0 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Toronto_ISPRS.tbz and b/tests/data/cowc_detection/COWC_Detection_Toronto_ISPRS.tbz differ diff --git a/tests/data/cowc_detection/COWC_Detection_Utah_AGRC.tbz b/tests/data/cowc_detection/COWC_Detection_Utah_AGRC.tbz index 57d2faff089..9385f26f0cc 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Utah_AGRC.tbz and b/tests/data/cowc_detection/COWC_Detection_Utah_AGRC.tbz differ diff --git a/tests/data/cowc_detection/COWC_Detection_Vaihingen_ISPRS.tbz b/tests/data/cowc_detection/COWC_Detection_Vaihingen_ISPRS.tbz index 76c5ee0f37e..61b737c64a8 100644 Binary files a/tests/data/cowc_detection/COWC_Detection_Vaihingen_ISPRS.tbz and b/tests/data/cowc_detection/COWC_Detection_Vaihingen_ISPRS.tbz differ diff --git a/tests/data/cowc_detection/COWC_test_list_detection.txt b/tests/data/cowc_detection/COWC_test_list_detection.txt index ec3ddbab651..583e5231d41 100644 --- a/tests/data/cowc_detection/COWC_test_list_detection.txt +++ b/tests/data/cowc_detection/COWC_test_list_detection.txt @@ -1,6 +1,6 @@ -Toronto_ISPRS/test/fake_01.png 0 -Selwyn_LINZ/test/fake_03.png 1 -Potsdam_ISPRS/test/fake_05.png 1 -Vaihingen_ISPRS/test/fake_07.png 0 -Columbus_CSUAV_AFRL/test/fake_09.png 1 -Utah_AGRC/test/fake_11.png 1 +Toronto_ISPRS/test/fake_01.png 1 +Selwyn_LINZ/test/fake_03.png 1 +Potsdam_ISPRS/test/fake_05.png 1 +Vaihingen_ISPRS/test/fake_07.png 0 +Columbus_CSUAV_AFRL/test/fake_09.png 0 +Utah_AGRC/test/fake_11.png 0 diff --git a/tests/data/cowc_detection/COWC_test_list_detection.txt.bz2 b/tests/data/cowc_detection/COWC_test_list_detection.txt.bz2 index 9d82748e4e9..45b56567b03 100644 Binary files a/tests/data/cowc_detection/COWC_test_list_detection.txt.bz2 and b/tests/data/cowc_detection/COWC_test_list_detection.txt.bz2 differ diff --git a/tests/data/cowc_detection/COWC_train_list_detection.txt b/tests/data/cowc_detection/COWC_train_list_detection.txt index dfc082630c8..2eb48c8fa3b 100644 --- a/tests/data/cowc_detection/COWC_train_list_detection.txt +++ b/tests/data/cowc_detection/COWC_train_list_detection.txt @@ -1,12 +1,12 @@ -Toronto_ISPRS/train/fake_01.png 0 -Toronto_ISPRS/train/fake_02.png 1 -Selwyn_LINZ/train/fake_03.png 1 -Selwyn_LINZ/train/fake_04.png 0 -Potsdam_ISPRS/train/fake_05.png 1 -Potsdam_ISPRS/train/fake_06.png 1 -Vaihingen_ISPRS/train/fake_07.png 0 -Vaihingen_ISPRS/train/fake_08.png 0 -Columbus_CSUAV_AFRL/train/fake_09.png 1 -Columbus_CSUAV_AFRL/train/fake_10.png 1 -Utah_AGRC/train/fake_11.png 1 -Utah_AGRC/train/fake_12.png 1 +Toronto_ISPRS/train/fake_01.png 1 +Toronto_ISPRS/train/fake_02.png 0 +Selwyn_LINZ/train/fake_03.png 1 +Selwyn_LINZ/train/fake_04.png 1 +Potsdam_ISPRS/train/fake_05.png 1 +Potsdam_ISPRS/train/fake_06.png 1 +Vaihingen_ISPRS/train/fake_07.png 0 +Vaihingen_ISPRS/train/fake_08.png 1 +Columbus_CSUAV_AFRL/train/fake_09.png 0 +Columbus_CSUAV_AFRL/train/fake_10.png 1 +Utah_AGRC/train/fake_11.png 1 +Utah_AGRC/train/fake_12.png 0 diff --git a/tests/data/cowc_detection/COWC_train_list_detection.txt.bz2 b/tests/data/cowc_detection/COWC_train_list_detection.txt.bz2 index 4484776bbbb..0dcfe35b8da 100644 Binary files a/tests/data/cowc_detection/COWC_train_list_detection.txt.bz2 and b/tests/data/cowc_detection/COWC_train_list_detection.txt.bz2 differ diff --git a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/test/fake_09.png b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/test/fake_09.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/test/fake_09.png and b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/test/fake_09.png differ diff --git a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_09.png b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_09.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_09.png and b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_09.png differ diff --git a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_10.png b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_10.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_10.png and b/tests/data/cowc_detection/Columbus_CSUAV_AFRL/train/fake_10.png differ diff --git a/tests/data/cowc_detection/Potsdam_ISPRS/test/fake_05.png b/tests/data/cowc_detection/Potsdam_ISPRS/test/fake_05.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Potsdam_ISPRS/test/fake_05.png and b/tests/data/cowc_detection/Potsdam_ISPRS/test/fake_05.png differ diff --git a/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_05.png b/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_05.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_05.png and b/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_05.png differ diff --git a/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_06.png b/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_06.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_06.png and b/tests/data/cowc_detection/Potsdam_ISPRS/train/fake_06.png differ diff --git a/tests/data/cowc_detection/Selwyn_LINZ/test/fake_03.png b/tests/data/cowc_detection/Selwyn_LINZ/test/fake_03.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Selwyn_LINZ/test/fake_03.png and b/tests/data/cowc_detection/Selwyn_LINZ/test/fake_03.png differ diff --git a/tests/data/cowc_detection/Selwyn_LINZ/train/fake_03.png b/tests/data/cowc_detection/Selwyn_LINZ/train/fake_03.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Selwyn_LINZ/train/fake_03.png and b/tests/data/cowc_detection/Selwyn_LINZ/train/fake_03.png differ diff --git a/tests/data/cowc_detection/Selwyn_LINZ/train/fake_04.png b/tests/data/cowc_detection/Selwyn_LINZ/train/fake_04.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Selwyn_LINZ/train/fake_04.png and b/tests/data/cowc_detection/Selwyn_LINZ/train/fake_04.png differ diff --git a/tests/data/cowc_detection/Toronto_ISPRS/test/fake_01.png b/tests/data/cowc_detection/Toronto_ISPRS/test/fake_01.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Toronto_ISPRS/test/fake_01.png and b/tests/data/cowc_detection/Toronto_ISPRS/test/fake_01.png differ diff --git a/tests/data/cowc_detection/Toronto_ISPRS/train/fake_01.png b/tests/data/cowc_detection/Toronto_ISPRS/train/fake_01.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Toronto_ISPRS/train/fake_01.png and b/tests/data/cowc_detection/Toronto_ISPRS/train/fake_01.png differ diff --git a/tests/data/cowc_detection/Toronto_ISPRS/train/fake_02.png b/tests/data/cowc_detection/Toronto_ISPRS/train/fake_02.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Toronto_ISPRS/train/fake_02.png and b/tests/data/cowc_detection/Toronto_ISPRS/train/fake_02.png differ diff --git a/tests/data/cowc_detection/Utah_AGRC/test/fake_11.png b/tests/data/cowc_detection/Utah_AGRC/test/fake_11.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Utah_AGRC/test/fake_11.png and b/tests/data/cowc_detection/Utah_AGRC/test/fake_11.png differ diff --git a/tests/data/cowc_detection/Utah_AGRC/train/fake_11.png b/tests/data/cowc_detection/Utah_AGRC/train/fake_11.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Utah_AGRC/train/fake_11.png and b/tests/data/cowc_detection/Utah_AGRC/train/fake_11.png differ diff --git a/tests/data/cowc_detection/Utah_AGRC/train/fake_12.png b/tests/data/cowc_detection/Utah_AGRC/train/fake_12.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Utah_AGRC/train/fake_12.png and b/tests/data/cowc_detection/Utah_AGRC/train/fake_12.png differ diff --git a/tests/data/cowc_detection/Vaihingen_ISPRS/test/fake_07.png b/tests/data/cowc_detection/Vaihingen_ISPRS/test/fake_07.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Vaihingen_ISPRS/test/fake_07.png and b/tests/data/cowc_detection/Vaihingen_ISPRS/test/fake_07.png differ diff --git a/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_07.png b/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_07.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_07.png and b/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_07.png differ diff --git a/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_08.png b/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_08.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_08.png and b/tests/data/cowc_detection/Vaihingen_ISPRS/train/fake_08.png differ diff --git a/tests/data/cowc_detection/data.py b/tests/data/cowc_detection/data.py new file mode 100755 index 00000000000..f43a57e6439 --- /dev/null +++ b/tests/data/cowc_detection/data.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import bz2 +import csv +import hashlib +import glob +import os +import random +import shutil + +from PIL import Image + + +SIZE = 64 # image width/height +STOP = 2 # range of values for labels +PREFIX = "Detection" +SUFFIX = "detection" + +random.seed(0) + +sites = [ + "Toronto_ISPRS", + "Selwyn_LINZ", + "Potsdam_ISPRS", + "Vaihingen_ISPRS", + "Columbus_CSUAV_AFRL", + "Utah_AGRC", +] + +# Remove old data +for filename in glob.glob("COWC_*"): + os.remove(filename) +for site in sites: + if os.path.exists(site): + shutil.rmtree(site) + +i = 1 +data_list = {"train": [], "test": []} +image_md5s = [] +for site in sites: + # Create images + for split in ["test", "train", "train"]: + directory = os.path.join(site, split) + os.makedirs(directory, exist_ok=True) + filename = os.path.join(directory, f"fake_{i:02}.png") + + img = Image.new("RGB", (SIZE, SIZE)) + img.save(filename) + + data_list[split].append((filename, random.randrange(STOP))) + + if split == "train": + i += 1 + + # Compress images + filename = f"COWC_{PREFIX}_{site}.tbz" + bad_filename = shutil.make_archive(filename.replace(".tbz", ""), "bztar", ".", site) + os.rename(bad_filename, filename) + + # Compute checksums + with open(filename, "rb") as f: + image_md5s.append(hashlib.md5(f.read()).hexdigest()) + +label_md5s = [] +for split in ["train", "test"]: + # Create labels + filename = f"COWC_{split}_list_{SUFFIX}.txt" + with open(filename, "w", newline="") as csvfile: + csvwriter = csv.writer(csvfile, delimiter=" ") + csvwriter.writerows(data_list[split]) + + # Compress labels + with open(filename, "rb") as src: + with bz2.open(filename + ".bz2", "wb") as dst: + dst.write(src.read()) + + # Compute checksums + with open(filename + ".bz2", "rb") as f: + label_md5s.append(hashlib.md5(f.read()).hexdigest()) + +md5s = label_md5s + image_md5s +for md5 in md5s: + print(repr(md5) + ",") diff --git a/tests/data/etci2021/data.py b/tests/data/etci2021/data.py new file mode 100755 index 00000000000..03d14d640b4 --- /dev/null +++ b/tests/data/etci2021/data.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import hashlib +import os +import shutil + +from PIL import Image + +SIZE = 64 # image width/height + +metadatas = [ + { + "filename": "train.zip", + "directory": "train", + "subdirs": ["nebraska_20170108t002112", "bangladesh_20170314t115609"], + }, + { + "filename": "val_with_ref_labels.zip", + "directory": "test", + "subdirs": ["florence_20180510t231343", "florence_20180522t231344"], + }, + { + "filename": "test_without_ref_labels.zip", + "directory": "test_internal", + "subdirs": ["redrivernorth_20190104t002247", "redrivernorth_20190116t002247"], + }, +] + +tiles = ["vh", "vv", "water_body_label", "flood_label"] + +for metadata in metadatas: + filename = metadata["filename"] + directory = metadata["directory"] + + # Remove old data + if os.path.exists(filename): + os.remove(filename) + if os.path.exists(directory): + shutil.rmtree(directory) + + # Create images + for subdir in metadata["subdirs"]: + for tile in tiles: + if directory == "test_internal" and tile == "flood_label": + continue + + fn = f"{subdir}_x-0_y-0" + if tile in ["vh", "vv"]: + fn += f"_{tile}" + fn += ".png" + fd = os.path.join(directory, subdir, "tiles", tile) + os.makedirs(fd) + + img = Image.new("RGB", (SIZE, SIZE)) + img.save(os.path.join(fd, fn)) + + # Compress data + shutil.make_archive(filename.replace(".zip", ""), "zip", ".", directory) + + # Compute checksums + with open(filename, "rb") as f: + md5 = hashlib.md5(f.read()).hexdigest() + print(repr(filename) + ":", repr(md5) + ",") diff --git a/tests/data/etci2021/test/florence_20180510t231343/tiles/flood_label/florence_20180510t231343_x-0_y-0.png b/tests/data/etci2021/test/florence_20180510t231343/tiles/flood_label/florence_20180510t231343_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180510t231343/tiles/flood_label/florence_20180510t231343_x-0_y-0.png and b/tests/data/etci2021/test/florence_20180510t231343/tiles/flood_label/florence_20180510t231343_x-0_y-0.png differ diff --git a/tests/data/etci2021/test/florence_20180510t231343/tiles/vh/florence_20180510t231343_x-0_y-0_vh.png b/tests/data/etci2021/test/florence_20180510t231343/tiles/vh/florence_20180510t231343_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180510t231343/tiles/vh/florence_20180510t231343_x-0_y-0_vh.png and b/tests/data/etci2021/test/florence_20180510t231343/tiles/vh/florence_20180510t231343_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/test/florence_20180510t231343/tiles/vv/florence_20180510t231343_x-0_y-0_vv.png b/tests/data/etci2021/test/florence_20180510t231343/tiles/vv/florence_20180510t231343_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180510t231343/tiles/vv/florence_20180510t231343_x-0_y-0_vv.png and b/tests/data/etci2021/test/florence_20180510t231343/tiles/vv/florence_20180510t231343_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/test/florence_20180510t231343/tiles/water_body_label/florence_20180510t231343_x-0_y-0.png b/tests/data/etci2021/test/florence_20180510t231343/tiles/water_body_label/florence_20180510t231343_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180510t231343/tiles/water_body_label/florence_20180510t231343_x-0_y-0.png and b/tests/data/etci2021/test/florence_20180510t231343/tiles/water_body_label/florence_20180510t231343_x-0_y-0.png differ diff --git a/tests/data/etci2021/test/florence_20180522t231344/tiles/flood_label/florence_20180522t231344_x-0_y-0.png b/tests/data/etci2021/test/florence_20180522t231344/tiles/flood_label/florence_20180522t231344_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180522t231344/tiles/flood_label/florence_20180522t231344_x-0_y-0.png and b/tests/data/etci2021/test/florence_20180522t231344/tiles/flood_label/florence_20180522t231344_x-0_y-0.png differ diff --git a/tests/data/etci2021/test/florence_20180522t231344/tiles/vh/florence_20180522t231344_x-0_y-0_vh.png b/tests/data/etci2021/test/florence_20180522t231344/tiles/vh/florence_20180522t231344_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180522t231344/tiles/vh/florence_20180522t231344_x-0_y-0_vh.png and b/tests/data/etci2021/test/florence_20180522t231344/tiles/vh/florence_20180522t231344_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/test/florence_20180522t231344/tiles/vv/florence_20180522t231344_x-0_y-0_vv.png b/tests/data/etci2021/test/florence_20180522t231344/tiles/vv/florence_20180522t231344_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180522t231344/tiles/vv/florence_20180522t231344_x-0_y-0_vv.png and b/tests/data/etci2021/test/florence_20180522t231344/tiles/vv/florence_20180522t231344_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/test/florence_20180522t231344/tiles/water_body_label/florence_20180522t231344_x-0_y-0.png b/tests/data/etci2021/test/florence_20180522t231344/tiles/water_body_label/florence_20180522t231344_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test/florence_20180522t231344/tiles/water_body_label/florence_20180522t231344_x-0_y-0.png and b/tests/data/etci2021/test/florence_20180522t231344/tiles/water_body_label/florence_20180522t231344_x-0_y-0.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vh/redrivernorth_20190104t002247_x-0_y-0_vh.png b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vh/redrivernorth_20190104t002247_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vh/redrivernorth_20190104t002247_x-0_y-0_vh.png and b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vh/redrivernorth_20190104t002247_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vv/redrivernorth_20190104t002247_x-0_y-0_vv.png b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vv/redrivernorth_20190104t002247_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vv/redrivernorth_20190104t002247_x-0_y-0_vv.png and b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/vv/redrivernorth_20190104t002247_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/water_body_label/redrivernorth_20190104t002247_x-0_y-0.png b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/water_body_label/redrivernorth_20190104t002247_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/water_body_label/redrivernorth_20190104t002247_x-0_y-0.png and b/tests/data/etci2021/test_internal/redrivernorth_20190104t002247/tiles/water_body_label/redrivernorth_20190104t002247_x-0_y-0.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vh/redrivernorth_20190116t002247_x-0_y-0_vh.png b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vh/redrivernorth_20190116t002247_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vh/redrivernorth_20190116t002247_x-0_y-0_vh.png and b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vh/redrivernorth_20190116t002247_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vv/redrivernorth_20190116t002247_x-0_y-0_vv.png b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vv/redrivernorth_20190116t002247_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vv/redrivernorth_20190116t002247_x-0_y-0_vv.png and b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/vv/redrivernorth_20190116t002247_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/water_body_label/redrivernorth_20190116t002247_x-0_y-0.png b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/water_body_label/redrivernorth_20190116t002247_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/water_body_label/redrivernorth_20190116t002247_x-0_y-0.png and b/tests/data/etci2021/test_internal/redrivernorth_20190116t002247/tiles/water_body_label/redrivernorth_20190116t002247_x-0_y-0.png differ diff --git a/tests/data/etci2021/test_without_ref_labels.zip b/tests/data/etci2021/test_without_ref_labels.zip index 0f94a1e4ce5..34e062dbc3e 100644 Binary files a/tests/data/etci2021/test_without_ref_labels.zip and b/tests/data/etci2021/test_without_ref_labels.zip differ diff --git a/tests/data/etci2021/train.zip b/tests/data/etci2021/train.zip index 5cba717d7a1..b24e36421b2 100644 Binary files a/tests/data/etci2021/train.zip and b/tests/data/etci2021/train.zip differ diff --git a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/flood_label/bangladesh_20170314t115609_x-0_y-0.png b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/flood_label/bangladesh_20170314t115609_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/flood_label/bangladesh_20170314t115609_x-0_y-0.png and b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/flood_label/bangladesh_20170314t115609_x-0_y-0.png differ diff --git a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vh/bangladesh_20170314t115609_x-0_y-0_vh.png b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vh/bangladesh_20170314t115609_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vh/bangladesh_20170314t115609_x-0_y-0_vh.png and b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vh/bangladesh_20170314t115609_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vv/bangladesh_20170314t115609_x-0_y-0_vv.png b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vv/bangladesh_20170314t115609_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vv/bangladesh_20170314t115609_x-0_y-0_vv.png and b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/vv/bangladesh_20170314t115609_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/water_body_label/bangladesh_20170314t115609_x-0_y-0.png b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/water_body_label/bangladesh_20170314t115609_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/water_body_label/bangladesh_20170314t115609_x-0_y-0.png and b/tests/data/etci2021/train/bangladesh_20170314t115609/tiles/water_body_label/bangladesh_20170314t115609_x-0_y-0.png differ diff --git a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/flood_label/nebraska_20170108t002112_x-0_y-0.png b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/flood_label/nebraska_20170108t002112_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/flood_label/nebraska_20170108t002112_x-0_y-0.png and b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/flood_label/nebraska_20170108t002112_x-0_y-0.png differ diff --git a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vh/nebraska_20170108t002112_x-0_y-0_vh.png b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vh/nebraska_20170108t002112_x-0_y-0_vh.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vh/nebraska_20170108t002112_x-0_y-0_vh.png and b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vh/nebraska_20170108t002112_x-0_y-0_vh.png differ diff --git a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vv/nebraska_20170108t002112_x-0_y-0_vv.png b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vv/nebraska_20170108t002112_x-0_y-0_vv.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vv/nebraska_20170108t002112_x-0_y-0_vv.png and b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/vv/nebraska_20170108t002112_x-0_y-0_vv.png differ diff --git a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/water_body_label/nebraska_20170108t002112_x-0_y-0.png b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/water_body_label/nebraska_20170108t002112_x-0_y-0.png index 19b3f6a1e4b..320c3449e5f 100644 Binary files a/tests/data/etci2021/train/nebraska_20170108t002112/tiles/water_body_label/nebraska_20170108t002112_x-0_y-0.png and b/tests/data/etci2021/train/nebraska_20170108t002112/tiles/water_body_label/nebraska_20170108t002112_x-0_y-0.png differ diff --git a/tests/data/etci2021/val_with_ref_labels.zip b/tests/data/etci2021/val_with_ref_labels.zip index acd6d76c332..6077f058efd 100644 Binary files a/tests/data/etci2021/val_with_ref_labels.zip and b/tests/data/etci2021/val_with_ref_labels.zip differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images.zip b/tests/data/oscd/Onera Satellite Change Detection dataset - Images.zip index 9a6cb41a1b9..e686d175811 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images.zip and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images.zip differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/dates.txt b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/dates.txt index fa2ff53aa38..7ee094e0852 100644 --- a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/dates.txt +++ b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/dates.txt @@ -1,2 +1,2 @@ -date_1: 20151211 -date_2: 20180330 +date_1: 20161130 +date_2: 20170829 diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B01.tif index a3ee8290f6a..31595ee57ee 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B02.tif index a3ee8290f6a..5e14a9b525a 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B03.tif index a3ee8290f6a..6ac049ea88b 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B04.tif index a3ee8290f6a..718b05845f1 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B05.tif index a3ee8290f6a..c6356789554 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B06.tif index a3ee8290f6a..48b17dda24f 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B07.tif index a3ee8290f6a..acf9bfb4cee 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B08.tif index a3ee8290f6a..b9eefaaa743 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B09.tif index a3ee8290f6a..5120b3b91d2 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B10.tif index a3ee8290f6a..b5b6e436327 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B11.tif index a3ee8290f6a..047a39938ff 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B12.tif index a3ee8290f6a..e47a97810de 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B8A.tif index a3ee8290f6a..0be3b5f5bcf 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_1_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B01.tif index a3ee8290f6a..a7c74bb99e9 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B02.tif index a3ee8290f6a..9809f480283 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B03.tif index a3ee8290f6a..5d891f19bf1 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B04.tif index a3ee8290f6a..3989aa999e7 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B05.tif index a3ee8290f6a..323f1629690 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B06.tif index a3ee8290f6a..647bac56eed 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B07.tif index a3ee8290f6a..895e6c6b789 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B08.tif index a3ee8290f6a..8067466b418 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B09.tif index a3ee8290f6a..e95a142bf60 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B10.tif index a3ee8290f6a..39f65baa3f5 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B11.tif index a3ee8290f6a..ec0879ca82c 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B12.tif index a3ee8290f6a..92b30223833 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B8A.tif index a3ee8290f6a..1b130a20bf6 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/test/imgs_2_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B01.tif index a3ee8290f6a..0fb1192178d 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B02.tif index a3ee8290f6a..848c4441980 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B03.tif index a3ee8290f6a..df966b575f9 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B04.tif index a3ee8290f6a..93d01cb2a79 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B05.tif index a3ee8290f6a..50a214cdf56 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B06.tif index a3ee8290f6a..56751414a67 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B07.tif index a3ee8290f6a..ea57e5466b5 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B08.tif index a3ee8290f6a..5dbc33d5122 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B09.tif index a3ee8290f6a..fb3c4ada78c 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B10.tif index a3ee8290f6a..8b7528cefb6 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B11.tif index a3ee8290f6a..c742ef9091c 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B12.tif index a3ee8290f6a..e285b7cb8e2 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B8A.tif index a3ee8290f6a..8dad3bd0b35 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_1_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B01.tif index a3ee8290f6a..b61a82720ed 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B02.tif index a3ee8290f6a..49af5358221 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B03.tif index a3ee8290f6a..5d0a0a07cfb 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B04.tif index a3ee8290f6a..dea8b061347 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B05.tif index a3ee8290f6a..bc688d18120 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B06.tif index a3ee8290f6a..c05df52d962 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B07.tif index a3ee8290f6a..2b432d47c81 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B08.tif index a3ee8290f6a..96ce65b4923 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B09.tif index a3ee8290f6a..d4e1b17c5af 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B10.tif index a3ee8290f6a..8747b6b4fe8 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B11.tif index a3ee8290f6a..2b024f607d0 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B12.tif index a3ee8290f6a..0c2643b23f7 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B8A.tif index a3ee8290f6a..26048023330 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train1/imgs_2_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B01.tif index a3ee8290f6a..b64da370d6b 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B02.tif index a3ee8290f6a..3ec91badd61 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B03.tif index a3ee8290f6a..28a3a7192e7 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B04.tif index a3ee8290f6a..c6231ff3c15 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B05.tif index a3ee8290f6a..29dfd694763 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B06.tif index a3ee8290f6a..ff8430de80b 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B07.tif index a3ee8290f6a..f093b329dc6 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B08.tif index a3ee8290f6a..54a404a54ff 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B09.tif index a3ee8290f6a..d3a60ecdb96 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B10.tif index a3ee8290f6a..cd13329201b 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B11.tif index a3ee8290f6a..a1ca762b10e 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B12.tif index a3ee8290f6a..135c138b1fb 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B8A.tif index a3ee8290f6a..33066a9c723 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_1_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B01.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B01.tif index a3ee8290f6a..1b0efa4bde1 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B01.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B01.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B02.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B02.tif index a3ee8290f6a..f7f9baf720e 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B02.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B02.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B03.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B03.tif index a3ee8290f6a..e04bc7a7eca 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B03.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B03.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B04.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B04.tif index a3ee8290f6a..e1ef595b16a 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B04.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B04.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B05.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B05.tif index a3ee8290f6a..c0d140aaa7d 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B05.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B05.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B06.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B06.tif index a3ee8290f6a..2c0614824bf 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B06.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B06.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B07.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B07.tif index a3ee8290f6a..2e100588d73 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B07.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B07.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B08.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B08.tif index a3ee8290f6a..03e0da41934 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B08.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B08.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B09.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B09.tif index a3ee8290f6a..a4a1c1fb076 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B09.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B09.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B10.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B10.tif index a3ee8290f6a..99e4f640035 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B10.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B10.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B11.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B11.tif index a3ee8290f6a..e4704ad5969 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B11.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B11.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B12.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B12.tif index a3ee8290f6a..6db801c9dde 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B12.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B12.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B8A.tif b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B8A.tif index a3ee8290f6a..00c9abada70 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B8A.tif and b/tests/data/oscd/Onera Satellite Change Detection dataset - Images/train2/imgs_2_rect/B8A.tif differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels.zip b/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels.zip index 04ec4f8e338..ce1415975d0 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels.zip and b/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels.zip differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels/test/cm/cm.png b/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels/test/cm/cm.png index 337cd665214..3abc8741c86 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels/test/cm/cm.png and b/tests/data/oscd/Onera Satellite Change Detection dataset - Test Labels/test/cm/cm.png differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels.zip b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels.zip index 4332a78b828..6a91068749e 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels.zip and b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels.zip differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train1/cm/cm.png b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train1/cm/cm.png index 337cd665214..131f6e25241 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train1/cm/cm.png and b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train1/cm/cm.png differ diff --git a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train2/cm/cm.png b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train2/cm/cm.png index 337cd665214..a6869542b63 100644 Binary files a/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train2/cm/cm.png and b/tests/data/oscd/Onera Satellite Change Detection dataset - Train Labels/train2/cm/cm.png differ diff --git a/tests/data/oscd/data.py b/tests/data/oscd/data.py new file mode 100755 index 00000000000..9f576720eee --- /dev/null +++ b/tests/data/oscd/data.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import hashlib +import os +import shutil + +import numpy as np +from PIL import Image + + +SIZE = 64 # image width/height + +np.random.seed(0) + +directories = [ + "Onera Satellite Change Detection dataset - Images", + "Onera Satellite Change Detection dataset - Train Labels", + "Onera Satellite Change Detection dataset - Test Labels", +] +bands = [ + "B01", + "B02", + "B03", + "B04", + "B05", + "B06", + "B07", + "B08", + "B09", + "B10", + "B11", + "B12", + "B8A", +] + +# Remove old data +for directory in directories: + filename = f"{directory}.zip" + + if os.path.exists(filename): + os.remove(filename) + if os.path.exists(directory): + shutil.rmtree(directory) + +# Create images +for subdir in ["train1", "train2", "test"]: + for rect in ["imgs_1_rect", "imgs_2_rect"]: + directory = os.path.join(directories[0], subdir, rect) + os.makedirs(directory) + + for band in bands: + filename = os.path.join(directory, f"{band}.tif") + arr = np.random.randint( + np.iinfo(np.uint16).max, size=(SIZE, SIZE), dtype=np.uint16 + ) + img = Image.fromarray(arr) + img.save(filename) + + filename = os.path.join(directories[0], subdir, "dates.txt") + with open(filename, "w") as f: + for key, value in [("date_1", "20161130"), ("date_2", "20170829")]: + f.write(f"{key}: {value}\n") + +# Create labels +for i, subdir in [(1, "train1"), (1, "train2"), (2, "test")]: + directory = os.path.join(directories[i], subdir, "cm") + os.makedirs(directory) + filename = os.path.join(directory, "cm.png") + arr = np.random.randint(np.iinfo(np.uint8).max, size=(SIZE, SIZE), dtype=np.uint8) + img = Image.fromarray(arr) + img.save(filename) + +for directory in directories: + # Compress data + shutil.make_archive(directory, "zip", ".", directory) + + # Compute checksums + filename = f"{directory}.zip" + with open(filename, "rb") as f: + md5 = hashlib.md5(f.read()).hexdigest() + print(repr(filename) + ": " + repr(md5) + ",") diff --git a/tests/data/so2sat/data.py b/tests/data/so2sat/data.py new file mode 100755 index 00000000000..f0a2c01f2aa --- /dev/null +++ b/tests/data/so2sat/data.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +import hashlib +import os + +import h5py +import numpy as np + + +SIZE = 64 # image width/height +NUM_CLASSES = 17 +NUM_SAMPLES = 1 + +np.random.seed(0) + +for split in ["training", "validation", "testing"]: + filename = f"{split}.h5" + + # Remove old data + if os.path.exists(filename): + os.remove(filename) + + # Random one hot encoding + label = np.eye(NUM_CLASSES, dtype=np.uint8)[ + np.random.choice(NUM_CLASSES, NUM_SAMPLES) + ] + + # Random images + sen1 = np.random.randint(256, size=(NUM_SAMPLES, SIZE, SIZE, 8), dtype=np.uint8) + sen2 = np.random.randint(256, size=(NUM_SAMPLES, SIZE, SIZE, 10), dtype=np.uint8) + + # Create datasets + with h5py.File(filename, "w") as f: + f.create_dataset("label", data=label) + f.create_dataset("sen1", data=sen1) + f.create_dataset("sen2", data=sen2) + + # Compute checksums + with open(filename, "rb") as f: + md5 = hashlib.md5(f.read()).hexdigest() + print(repr(split.replace("ing", "")) + ":", repr(md5) + ",") diff --git a/tests/data/so2sat/testing.h5 b/tests/data/so2sat/testing.h5 index 51169280abb..464108e4b9d 100644 Binary files a/tests/data/so2sat/testing.h5 and b/tests/data/so2sat/testing.h5 differ diff --git a/tests/data/so2sat/training.h5 b/tests/data/so2sat/training.h5 index 7de7b665c33..b433518217f 100644 Binary files a/tests/data/so2sat/training.h5 and b/tests/data/so2sat/training.h5 differ diff --git a/tests/data/so2sat/validation.h5 b/tests/data/so2sat/validation.h5 index f959a2aced6..a1ec7f5d1da 100644 Binary files a/tests/data/so2sat/validation.h5 and b/tests/data/so2sat/validation.h5 differ diff --git a/tests/datamodules/test_bigearthnet.py b/tests/datamodules/test_bigearthnet.py deleted file mode 100644 index b460877a76a..00000000000 --- a/tests/datamodules/test_bigearthnet.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest -from _pytest.fixtures import SubRequest - -from torchgeo.datamodules import BigEarthNetDataModule - - -class TestBigEarthNetDataModule: - @pytest.fixture(scope="class", params=["s1", "s2", "all"]) - def datamodule(self, request: SubRequest) -> BigEarthNetDataModule: - bands = request.param - root = os.path.join("tests", "data", "bigearthnet") - num_classes = 19 - batch_size = 1 - num_workers = 0 - dm = BigEarthNetDataModule(root, bands, num_classes, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: BigEarthNetDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: BigEarthNetDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: BigEarthNetDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_chesapeake.py b/tests/datamodules/test_chesapeake.py index 2d4fd63a4ba..4dde9bbf428 100644 --- a/tests/datamodules/test_chesapeake.py +++ b/tests/datamodules/test_chesapeake.py @@ -2,41 +2,28 @@ # Licensed under the MIT License. import os +from typing import Any, Dict, cast import pytest import torch -from _pytest.fixtures import SubRequest +from omegaconf import OmegaConf from torchgeo.datamodules import ChesapeakeCVPRDataModule class TestChesapeakeCVPRDataModule: - @pytest.fixture(scope="class", params=[(5, True), (5, False), (7, False)]) - def datamodule(self, request: SubRequest) -> ChesapeakeCVPRDataModule: - dm = ChesapeakeCVPRDataModule( - os.path.join("tests", "data", "chesapeake", "cvpr"), - ["de-test"], - ["de-test"], - ["de-test"], - patch_size=32, - patches_per_tile=2, - batch_size=2, - num_workers=0, - class_set=request.param[0], - use_prior_labels=request.param[1], + @pytest.fixture(scope="class") + def datamodule(self) -> ChesapeakeCVPRDataModule: + conf = OmegaConf.load( + os.path.join("conf", "task_defaults", "chesapeake_cvpr_5.yaml") ) - dm.prepare_data() - dm.setup() - return dm + kwargs = OmegaConf.to_object(conf.experiment.datamodule) + kwargs = cast(Dict[str, Any], kwargs) - def test_train_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: - next(iter(datamodule.test_dataloader())) + datamodule = ChesapeakeCVPRDataModule(**kwargs) + datamodule.prepare_data() + datamodule.setup() + return datamodule def test_nodata_check(self, datamodule: ChesapeakeCVPRDataModule) -> None: nodata_check = datamodule.nodata_check(4) diff --git a/tests/datamodules/test_cowc.py b/tests/datamodules/test_cowc.py deleted file mode 100644 index 8b6e974f35b..00000000000 --- a/tests/datamodules/test_cowc.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import COWCCountingDataModule - - -class TestCOWCCountingDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> COWCCountingDataModule: - root = os.path.join("tests", "data", "cowc_counting") - seed = 0 - batch_size = 1 - num_workers = 0 - dm = COWCCountingDataModule(root, seed, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: COWCCountingDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: COWCCountingDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: COWCCountingDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_cyclone.py b/tests/datamodules/test_cyclone.py deleted file mode 100644 index 843cc1656ed..00000000000 --- a/tests/datamodules/test_cyclone.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import CycloneDataModule - - -class TestCycloneDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> CycloneDataModule: - root = os.path.join("tests", "data", "cyclone") - seed = 0 - batch_size = 1 - num_workers = 0 - dm = CycloneDataModule(root, seed, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: CycloneDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: CycloneDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: CycloneDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_etci2021.py b/tests/datamodules/test_etci2021.py deleted file mode 100644 index b51e8daf1b1..00000000000 --- a/tests/datamodules/test_etci2021.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import ETCI2021DataModule - - -class TestETCI2021DataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> ETCI2021DataModule: - root = os.path.join("tests", "data", "etci2021") - seed = 0 - batch_size = 2 - num_workers = 0 - dm = ETCI2021DataModule(root, seed, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: ETCI2021DataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: ETCI2021DataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: ETCI2021DataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_eurosat.py b/tests/datamodules/test_eurosat.py deleted file mode 100644 index a8a51cd7b53..00000000000 --- a/tests/datamodules/test_eurosat.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import EuroSATDataModule - - -class TestEuroSATDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> EuroSATDataModule: - root = os.path.join("tests", "data", "eurosat") - batch_size = 1 - num_workers = 0 - dm = EuroSATDataModule(root, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: EuroSATDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: EuroSATDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: EuroSATDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_landcoverai.py b/tests/datamodules/test_landcoverai.py deleted file mode 100644 index 1d4f2e43150..00000000000 --- a/tests/datamodules/test_landcoverai.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import LandCoverAIDataModule - - -class TestLandCoverAIDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> LandCoverAIDataModule: - root = os.path.join("tests", "data", "landcoverai") - batch_size = 2 - num_workers = 0 - dm = LandCoverAIDataModule(root, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: LandCoverAIDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: LandCoverAIDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: LandCoverAIDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_naip.py b/tests/datamodules/test_naip.py deleted file mode 100644 index 5f9d676f2ba..00000000000 --- a/tests/datamodules/test_naip.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import NAIPChesapeakeDataModule - - -class TestNAIPChesapeakeDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> NAIPChesapeakeDataModule: - dm = NAIPChesapeakeDataModule( - os.path.join("tests", "data", "naip"), - os.path.join("tests", "data", "chesapeake", "BAYWIDE"), - batch_size=2, - num_workers=0, - ) - dm.patch_size = 32 - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: NAIPChesapeakeDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: NAIPChesapeakeDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: NAIPChesapeakeDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_resisc45.py b/tests/datamodules/test_resisc45.py deleted file mode 100644 index e1b9baa83f5..00000000000 --- a/tests/datamodules/test_resisc45.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import RESISC45DataModule - - -class TestRESISC45DataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> RESISC45DataModule: - root = os.path.join("tests", "data", "resisc45") - batch_size = 2 - num_workers = 0 - dm = RESISC45DataModule(root, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: RESISC45DataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: RESISC45DataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: RESISC45DataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_sen12ms.py b/tests/datamodules/test_sen12ms.py deleted file mode 100644 index 7cd6df73857..00000000000 --- a/tests/datamodules/test_sen12ms.py +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest -from _pytest.fixtures import SubRequest - -from torchgeo.datamodules import SEN12MSDataModule - - -class TestSEN12MSDataModule: - @pytest.fixture(scope="class", params=["all", "s1", "s2-all", "s2-reduced"]) - def datamodule(self, request: SubRequest) -> SEN12MSDataModule: - root = os.path.join("tests", "data", "sen12ms") - seed = 0 - bands = request.param - batch_size = 1 - num_workers = 0 - dm = SEN12MSDataModule(root, seed, bands, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: SEN12MSDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: SEN12MSDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: SEN12MSDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_so2sat.py b/tests/datamodules/test_so2sat.py deleted file mode 100644 index 2f732306901..00000000000 --- a/tests/datamodules/test_so2sat.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest -from _pytest.fixtures import SubRequest - -from torchgeo.datamodules import So2SatDataModule - -pytest.importorskip("h5py") - - -class TestSo2SatDataModule: - @pytest.fixture(scope="class", params=zip([True, False], ["rgb", "s2"])) - def datamodule(self, request: SubRequest) -> So2SatDataModule: - unsupervised_mode, bands = request.param - root = os.path.join("tests", "data", "so2sat") - batch_size = 2 - num_workers = 0 - dm = So2SatDataModule(root, batch_size, num_workers, bands, unsupervised_mode) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: So2SatDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: So2SatDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: So2SatDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datamodules/test_ucmerced.py b/tests/datamodules/test_ucmerced.py deleted file mode 100644 index 8dd7ab83360..00000000000 --- a/tests/datamodules/test_ucmerced.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -import os - -import pytest - -from torchgeo.datamodules import UCMercedDataModule - - -class TestUCMercedDataModule: - @pytest.fixture(scope="class") - def datamodule(self) -> UCMercedDataModule: - root = os.path.join("tests", "data", "ucmerced") - batch_size = 2 - num_workers = 0 - dm = UCMercedDataModule(root, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - def test_train_dataloader(self, datamodule: UCMercedDataModule) -> None: - next(iter(datamodule.train_dataloader())) - - def test_val_dataloader(self, datamodule: UCMercedDataModule) -> None: - next(iter(datamodule.val_dataloader())) - - def test_test_dataloader(self, datamodule: UCMercedDataModule) -> None: - next(iter(datamodule.test_dataloader())) diff --git a/tests/datasets/test_cowc.py b/tests/datasets/test_cowc.py index 209988d84d5..87bec26af27 100644 --- a/tests/datasets/test_cowc.py +++ b/tests/datasets/test_cowc.py @@ -45,14 +45,14 @@ def dataset( COWCCounting, "base_url", base_url ) md5s = [ - "a729b6e29278a9a000aa349dad3c78cb", - "a8ff4c4de4b8c66bd9c5ec17f532b3a2", - "bc6b9493b8e39b87d189cadcc4823e05", - "f111948e2ac262c024c8fe32ba5b1434", - "8c333fcfa4168afa5376310958d15166", - "479670049aa9a48b4895cff6db3aa615", - "56043d4716ad0a1eedd392b0a543973b", - "b77193aef7c473379cd8d4e40d413137", + "7d0c6d1fb548d3ea3a182a56ce231f97", + "2e9a806b19b21f9d796c7393ad8f51ee", + "39453c0627effd908e773c5c1f8aecc9", + "67190b3e0ca8aa1fc93250aa5383a8f3", + "575aead6a0c92aba37d613895194da7c", + "e7c2279040d3ce31b9c925c45d0c61e2", + "f159e23d52bd0b5656fe296f427b98e1", + "0a4daed8c5f6c4e20faa6e38636e4346", ] monkeypatch.setattr(COWCCounting, "md5s", md5s) # type: ignore[attr-defined] root = str(tmp_path) @@ -116,14 +116,14 @@ def dataset( COWCDetection, "base_url", base_url ) md5s = [ - "cc913824d9aa6c7af6f957dcc2cb9690", - "f8e07e70958d8d57ab464f62e9abab80", - "6a481cd785b0f16e9e1ab016a0695e57", - "e9578491977d291def2611b84c84fdfd", - "0bb1c285b170c23a8590cf2926fd224e", - "60fa485b16c0e5b28db756fd1d8a0438", - "97c886fb7558f4e8779628917ca64596", - "ab21a117b754e04e65c63f94aa648e33", + "6bbbdb36ee4922e879f66ed9234cb8ab", + "09e4af08c6e6553afe5098b328ce9749", + "12a2708ab7644766e43f5aae34aa7f2a", + "a896433398a0c58263c0d266cfc93bc4", + "911ed42c104db60f7a7d03a5b36bc1ab", + "4cdb4fefab6a2951591e7840c11a229d", + "dd315cfb48dfa7ddb8230c942682bc37", + "dccc2257e9c4a9dde2b4f84769804046", ] monkeypatch.setattr(COWCDetection, "md5s", md5s) # type: ignore[attr-defined] root = str(tmp_path) diff --git a/tests/datasets/test_etci2021.py b/tests/datasets/test_etci2021.py index 89750dd0d1c..232fcd88976 100644 --- a/tests/datasets/test_etci2021.py +++ b/tests/datasets/test_etci2021.py @@ -36,19 +36,19 @@ def dataset( metadata = { "train": { "filename": "train.zip", - "md5": "50c10eb07d6db9aee3ba36401e4a2c45", + "md5": "ebbd2e65cd10621bc2e90a230b474b8b", "directory": "train", "url": os.path.join(data_dir, "train.zip"), }, "val": { "filename": "val_with_ref_labels.zip", - "md5": "3e8b5a3cb95e6029e0e2c2d4b4ec6fba", + "md5": "efdd1fe6c90f5dfd267c88b86b237c2b", "directory": "test", "url": os.path.join(data_dir, "val_with_ref_labels.zip"), }, "test": { "filename": "test_without_ref_labels.zip", - "md5": "c8ee1e5d3e478761cd00ebc6f28b0ae7", + "md5": "bf1180143de5705fe95fa8490835d6d1", "directory": "test_internal", "url": os.path.join(data_dir, "test_without_ref_labels.zip"), }, diff --git a/tests/datasets/test_oscd.py b/tests/datasets/test_oscd.py index be61d08b8e0..a8e497cbc8d 100644 --- a/tests/datasets/test_oscd.py +++ b/tests/datasets/test_oscd.py @@ -34,8 +34,18 @@ def dataset( monkeypatch.setattr( # type: ignore[attr-defined] torchgeo.datasets.oscd, "download_url", download_url ) - md5 = "d6ebaae1ea0f3ae960af31531d394521" - monkeypatch.setattr(OSCD, "md5", md5) # type: ignore[attr-defined] + md5s = { + "Onera Satellite Change Detection dataset - Images.zip": ( + "fb4e3f54c3a31fd3f21f98cad4ddfb74" + ), + "Onera Satellite Change Detection dataset - Train Labels.zip": ( + "ca526434a60e9abdf97d528dc29e9f13" + ), + "Onera Satellite Change Detection dataset - Test Labels.zip": ( + "ca0ba73ba66d06fa4903e269ef12eb50" + ), + } + monkeypatch.setattr(OSCD, "md5s", md5s) # type: ignore[attr-defined] urls = { "Onera Satellite Change Detection dataset - Images.zip": os.path.join( "tests", diff --git a/tests/datasets/test_so2sat.py b/tests/datasets/test_so2sat.py index 7df9fe5dd2b..5229ea14bb4 100644 --- a/tests/datasets/test_so2sat.py +++ b/tests/datasets/test_so2sat.py @@ -24,9 +24,9 @@ def dataset( self, monkeypatch: Generator[MonkeyPatch, None, None], request: SubRequest ) -> So2Sat: md5s = { - "train": "2fa6b9d8995e3b6272af42719f05aaa2", - "validation": "fe3dbf74971766d5038f6cbc0b1390ae", - "test": "87d428eff44267ca642fc739cc442331", + "train": "82e0f2d51766b89cb905dbaf8275eb5b", + "validation": "bf292ae4737c1698b1a3c6f5e742e0e1", + "test": "9a3bbe181b038d4e51f122c4be3c569e", } monkeypatch.setattr(So2Sat, "md5s", md5s) # type: ignore[attr-defined] @@ -57,13 +57,13 @@ def test_getitem(self, dataset: So2Sat) -> None: assert isinstance(x["label"], torch.Tensor) def test_len(self, dataset: So2Sat) -> None: - assert len(dataset) == 10 + assert len(dataset) == 1 def test_out_of_bounds(self, dataset: So2Sat) -> None: # h5py at version 2.10.0 raises a ValueError instead of an IndexError so we # check for both here with pytest.raises((IndexError, ValueError)): - dataset[10] + dataset[1] def test_invalid_split(self) -> None: with pytest.raises(AssertionError): diff --git a/tests/test_train.py b/tests/test_train.py index 786dd6ad9fe..5b853caa130 100644 --- a/tests/test_train.py +++ b/tests/test_train.py @@ -132,36 +132,3 @@ def test_config_file(tmp_path: Path) -> None: ) args = [sys.executable, "train.py", "config_file=" + str(config_file)] subprocess.run(args, check=True) - - -@pytest.mark.parametrize( - "task", - [ - "bigearthnet", - "byol", - "chesapeake_cvpr", - "cowc_counting", - "cyclone", - "landcoverai", - "naipchesapeake", - "resisc45", - "sen12ms", - "so2sat", - "ucmerced", - ], -) -def test_tasks(task: str, tmp_path: Path) -> None: - output_dir = tmp_path / "output" - log_dir = tmp_path / "logs" - args = [ - sys.executable, - "train.py", - "experiment.name=test", - "program.output_dir=" + str(output_dir), - "program.log_dir=" + str(log_dir), - "trainer.fast_dev_run=1", - "experiment.task=" + task, - "program.overwrite=True", - "config_file=" + os.path.join("conf", "task_defaults", task + ".yaml"), - ] - subprocess.run(args, check=True) diff --git a/tests/trainers/test_byol.py b/tests/trainers/test_byol.py index 304d4a5bf17..bb661d185ad 100644 --- a/tests/trainers/test_byol.py +++ b/tests/trainers/test_byol.py @@ -2,22 +2,18 @@ # Licensed under the MIT License. import os -from typing import Any, Dict, Generator, cast +from typing import Any, Dict, Type, cast import pytest import torch.nn as nn -from _pytest.fixtures import SubRequest -from _pytest.monkeypatch import MonkeyPatch from omegaconf import OmegaConf -from pytorch_lightning.core.lightning import LightningModule +from pytorch_lightning import LightningDataModule, Trainer from torchvision.models import resnet18 from torchgeo.datamodules import ChesapeakeCVPRDataModule from torchgeo.trainers import BYOLTask from torchgeo.trainers.byol import BYOL, SimCLRAugmentation -from .test_utils import mocked_log - class TestBYOL: def test_custom_augment_fn(self) -> None: @@ -37,61 +33,37 @@ def test_custom_augment_fn(self) -> None: class TestBYOLTask: - @pytest.fixture(scope="class") - def datamodule(self) -> ChesapeakeCVPRDataModule: - dm = ChesapeakeCVPRDataModule( - os.path.join("tests", "data", "chesapeake", "cvpr"), - ["de-test"], - ["de-test"], - ["de-test"], - patch_size=4, - patches_per_tile=2, - batch_size=2, - num_workers=0, - ) - dm.prepare_data() - dm.setup() - return dm - - @pytest.fixture(params=["resnet18", "resnet50"]) - def config(self, request: SubRequest) -> Dict[str, Any]: - task_conf = OmegaConf.load(os.path.join("conf", "task_defaults", "byol.yaml")) - task_args = OmegaConf.to_object(task_conf.experiment.module) - task_args = cast(Dict[str, Any], task_args) - task_args["encoder"] = request.param - return task_args - - @pytest.fixture - def task( - self, config: Dict[str, Any], monkeypatch: Generator[MonkeyPatch, None, None] - ) -> LightningModule: - task = BYOLTask(**config) - monkeypatch.setattr(task, "log", mocked_log) # type: ignore[attr-defined] - return task - - def test_configure_optimizers(self, task: BYOLTask) -> None: - out = task.configure_optimizers() - assert "optimizer" in out - assert "lr_scheduler" in out + @pytest.mark.parametrize( + "name,classname", + [ + ("chesapeake_cvpr_7", ChesapeakeCVPRDataModule), + ("chesapeake_cvpr_prior", ChesapeakeCVPRDataModule), + ], + ) + def test_trainer(self, name: str, classname: Type[LightningDataModule]) -> None: + conf = OmegaConf.load(os.path.join("conf", "task_defaults", name + ".yaml")) + conf_dict = OmegaConf.to_object(conf.experiment) + conf_dict = cast(Dict[Any, Dict[Any, Any]], conf_dict) - def test_training( - self, datamodule: ChesapeakeCVPRDataModule, task: BYOLTask - ) -> None: - batch = next(iter(datamodule.train_dataloader())) - task.training_step(batch, 0) + # Instantiate datamodule + datamodule_kwargs = conf_dict["datamodule"] + datamodule = classname(**datamodule_kwargs) - def test_validation( - self, datamodule: ChesapeakeCVPRDataModule, task: BYOLTask - ) -> None: - batch = next(iter(datamodule.val_dataloader())) - task.validation_step(batch, 0) + # Instantiate model + model_kwargs = conf_dict["module"] + model = BYOLTask(**model_kwargs) - def test_test(self, datamodule: ChesapeakeCVPRDataModule, task: BYOLTask) -> None: - batch = next(iter(datamodule.test_dataloader())) - task.test_step(batch, 0) + # Instantiate trainer + trainer = Trainer(fast_dev_run=True, log_every_n_steps=1) + trainer.fit(model=model, datamodule=datamodule) + trainer.test(model=model, datamodule=datamodule) - def test_invalid_encoder(self, config: Dict[str, Any]) -> None: - config["encoder"] = "invalid_encoder" + def test_invalid_encoder(self) -> None: + kwargs = { + "in_channels": 1, + "imagenet_pretraining": False, + "encoder_name": "invalid_encoder", + } error_message = "Encoder type 'invalid_encoder' is not valid." with pytest.raises(ValueError, match=error_message): - BYOLTask(**config) + BYOLTask(**kwargs) diff --git a/tests/trainers/test_chesapeake.py b/tests/trainers/test_chesapeake.py index 920936802a7..377d4a85e35 100644 --- a/tests/trainers/test_chesapeake.py +++ b/tests/trainers/test_chesapeake.py @@ -40,11 +40,10 @@ def datamodule(self, class_set: int) -> ChesapeakeCVPRDataModule: @pytest.fixture def config(self, class_set: int) -> Dict[str, Any]: task_conf = OmegaConf.load( - os.path.join("conf", "task_defaults", "chesapeake_cvpr.yaml") + os.path.join("conf", "task_defaults", f"chesapeake_cvpr_{class_set}.yaml") ) task_args = OmegaConf.to_object(task_conf.experiment.module) task_args = cast(Dict[str, Any], task_args) - task_args["num_classes"] = class_set return task_args @pytest.fixture diff --git a/tests/trainers/test_classification.py b/tests/trainers/test_classification.py index 4033f7bf5ee..f2c091c75ee 100644 --- a/tests/trainers/test_classification.py +++ b/tests/trainers/test_classification.py @@ -2,250 +2,136 @@ # Licensed under the MIT License. import os -from typing import Any, Dict, Generator, Optional, cast +from typing import Any, Dict, Type, cast import pytest -import pytorch_lightning as pl -import torch -import torch.nn.functional as F -from _pytest.fixtures import SubRequest -from _pytest.monkeypatch import MonkeyPatch from omegaconf import OmegaConf -from torch import Tensor -from torch.utils.data import DataLoader, Dataset, TensorDataset - +from pytorch_lightning import LightningDataModule, Trainer + +from torchgeo.datamodules import ( + BigEarthNetDataModule, + EuroSATDataModule, + RESISC45DataModule, + So2SatDataModule, + UCMercedDataModule, +) from torchgeo.trainers import ClassificationTask, MultiLabelClassificationTask -from .test_utils import mocked_log - -class DummyDataset(Dataset): # type: ignore[type-arg] - def __init__(self, num_channels: int, num_classes: int, multilabel: bool) -> None: - x = torch.randn(10, num_channels, 128, 128) # (b, c, h, w) - y = torch.randint( # type: ignore[attr-defined] - 0, num_classes, size=(10,) - ) # (b,) +class TestClassificationTask: + @pytest.mark.parametrize( + "name,classname", + [ + ("eurosat", EuroSATDataModule), + ("resisc45", RESISC45DataModule), + ("so2sat_supervised", So2SatDataModule), + ("so2sat_unsupervised", So2SatDataModule), + ("ucmerced", UCMercedDataModule), + ], + ) + def test_trainer(self, name: str, classname: Type[LightningDataModule]) -> None: + if name == "so2sat": + pytest.importorskip("h5py") - if multilabel: - y = F.one_hot(y, num_classes=num_classes) # (b, classes) + conf = OmegaConf.load(os.path.join("conf", "task_defaults", name + ".yaml")) + conf_dict = OmegaConf.to_object(conf.experiment) + conf_dict = cast(Dict[Any, Dict[Any, Any]], conf_dict) - self.dataset = TensorDataset(x, y) + # Instantiate datamodule + datamodule_kwargs = conf_dict["datamodule"] + datamodule = classname(**datamodule_kwargs) - def __len__(self) -> int: - return len(self.dataset) + # Instantiate model + model_kwargs = conf_dict["module"] + model = ClassificationTask(**model_kwargs) - def __getitem__(self, idx: int) -> Dict[str, Tensor]: - x, y = self.dataset[idx] - sample = {"image": x, "label": y} - return sample + # Instantiate trainer + trainer = Trainer(fast_dev_run=True, log_every_n_steps=1) + trainer.fit(model=model, datamodule=datamodule) + trainer.test(model=model, datamodule=datamodule) + @pytest.fixture + def model_kwargs(self) -> Dict[Any, Any]: + return { + "classification_model": "resnet18", + "in_channels": 1, + "loss": "ce", + "num_classes": 1, + "weights": "random", + } + + def test_pretrained(self, model_kwargs: Dict[Any, Any], checkpoint: str) -> None: + model_kwargs["weights"] = checkpoint + with pytest.warns(UserWarning): + ClassificationTask(**model_kwargs) -class DummyDataModule(pl.LightningDataModule): - def __init__( - self, - num_channels: int, - num_classes: int, - multilabel: bool, - batch_size: int = 1, - num_workers: int = 0, + def test_invalid_pretrained( + self, model_kwargs: Dict[Any, Any], checkpoint: str ) -> None: - super().__init__() # type: ignore[no-untyped-call] - self.num_channels = num_channels - self.num_classes = num_classes - self.multilabel = multilabel - self.batch_size = batch_size - self.num_workers = num_workers - - def setup(self, stage: Optional[str] = None) -> None: - self.dataset = DummyDataset( - num_channels=self.num_channels, - num_classes=self.num_classes, - multilabel=self.multilabel, - ) - - def train_dataloader(self) -> DataLoader: # type: ignore[type-arg] - return DataLoader( - self.dataset, batch_size=self.batch_size, num_workers=self.num_workers - ) - - def val_dataloader(self) -> DataLoader: # type: ignore[type-arg] - return DataLoader( - self.dataset, batch_size=self.batch_size, num_workers=self.num_workers - ) - - def test_dataloader(self) -> DataLoader: # type: ignore[type-arg] - return DataLoader( - self.dataset, batch_size=self.batch_size, num_workers=self.num_workers - ) - + model_kwargs["weights"] = checkpoint + model_kwargs["classification_model"] = "resnet50" + match = "Trying to load resnet18 weights into a resnet50" + with pytest.raises(ValueError, match=match): + ClassificationTask(**model_kwargs) + + def test_invalid_loss(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["loss"] = "invalid_loss" + match = "Loss type 'invalid_loss' is not valid." + with pytest.raises(ValueError, match=match): + ClassificationTask(**model_kwargs) + + def test_invalid_model(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["classification_model"] = "invalid_model" + match = "Model type 'invalid_model' is not a valid timm model." + with pytest.raises(ValueError, match=match): + ClassificationTask(**model_kwargs) + + def test_invalid_weights(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["weights"] = "invalid_weights" + match = "Weight type 'invalid_weights' is not valid." + with pytest.raises(ValueError, match=match): + ClassificationTask(**model_kwargs) -class TestClassificationTask: - num_classes = 10 - - @pytest.fixture(scope="class", params=[2, 3, 5]) - def datamodule(self, request: SubRequest) -> DummyDataModule: - dm = DummyDataModule( - num_channels=request.param, - num_classes=self.num_classes, - multilabel=False, - batch_size=2, - num_workers=0, - ) - dm.prepare_data() - dm.setup() - return dm - - @pytest.fixture( - scope="class", - params=zip( - ["ce", "jaccard", "focal"], - ["random", "random", "random"], - ["resnet18", "hrnet_w18_small_v2", "tf_efficientnet_b0"], - ), +class TestMultiLabelClassificationTask: + @pytest.mark.parametrize( + "name,classname", + [ + ("bigearthnet_all", BigEarthNetDataModule), + ("bigearthnet_s1", BigEarthNetDataModule), + ("bigearthnet_s2", BigEarthNetDataModule), + ], ) - def config( - self, request: SubRequest, datamodule: DummyDataModule - ) -> Dict[str, Any]: - loss, weights, model = request.param - task_args: Dict[str, Any] = {} - task_args["classification_model"] = model - task_args["learning_rate"] = 3e-4 - task_args["learning_rate_schedule_patience"] = 6 - task_args["in_channels"] = datamodule.num_channels - task_args["loss"] = loss - task_args["num_classes"] = self.num_classes - task_args["weights"] = weights - return task_args + def test_trainer(self, name: str, classname: Type[LightningDataModule]) -> None: + conf = OmegaConf.load(os.path.join("conf", "task_defaults", name + ".yaml")) + conf_dict = OmegaConf.to_object(conf.experiment) + conf_dict = cast(Dict[Any, Dict[Any, Any]], conf_dict) - @pytest.fixture - def task( - self, config: Dict[str, Any], monkeypatch: Generator[MonkeyPatch, None, None] - ) -> ClassificationTask: - task = ClassificationTask(**config) - monkeypatch.setattr(task, "log", mocked_log) # type: ignore[attr-defined] - return task - - def test_configure_optimizers(self, task: ClassificationTask) -> None: - out = task.configure_optimizers() - assert "optimizer" in out - assert "lr_scheduler" in out - - def test_training( - self, datamodule: DummyDataModule, task: ClassificationTask - ) -> None: - batch = next(iter(datamodule.train_dataloader())) - task.training_step(batch, 0) - task.training_epoch_end(0) + # Instantiate datamodule + datamodule_kwargs = conf_dict["datamodule"] + datamodule = classname(**datamodule_kwargs) - def test_validation( - self, datamodule: DummyDataModule, task: ClassificationTask - ) -> None: - batch = next(iter(datamodule.val_dataloader())) - task.validation_step(batch, 0) - task.validation_epoch_end(0) - - def test_test(self, datamodule: DummyDataModule, task: ClassificationTask) -> None: - batch = next(iter(datamodule.test_dataloader())) - task.test_step(batch, 0) - task.test_epoch_end(0) - - def test_pretrained(self, checkpoint: str) -> None: - task_conf = OmegaConf.load(os.path.join("conf", "task_defaults", "so2sat.yaml")) - task_args = OmegaConf.to_object(task_conf.experiment.module) - task_args = cast(Dict[str, Any], task_args) - task_args["weights"] = checkpoint - with pytest.warns(UserWarning): - ClassificationTask(**task_args) - - def test_invalid_model(self, config: Dict[str, Any]) -> None: - config["classification_model"] = "invalid_model" - error_message = "Model type 'invalid_model' is not a valid timm model." - with pytest.raises(ValueError, match=error_message): - ClassificationTask(**config) - - def test_invalid_loss(self, config: Dict[str, Any]) -> None: - config["loss"] = "invalid_loss" - config["classification_model"] = "resnet18" - error_message = "Loss type 'invalid_loss' is not valid." - with pytest.raises(ValueError, match=error_message): - ClassificationTask(**config) - - def test_invalid_weights(self, config: Dict[str, Any]) -> None: - config["weights"] = "invalid_weights" - error_message = "Weight type 'invalid_weights' is not valid." - with pytest.raises(ValueError, match=error_message): - ClassificationTask(**config) - - def test_invalid_pretrained(self, checkpoint: str, config: Dict[str, Any]) -> None: - config["weights"] = checkpoint - config["classification_model"] = "resnet50" - error_message = "Trying to load resnet18 weights into a resnet50" - with pytest.raises(ValueError, match=error_message): - ClassificationTask(**config) + # Instantiate model + model_kwargs = conf_dict["module"] + model = MultiLabelClassificationTask(**model_kwargs) - -class TestMultiLabelClassificationTask: - - num_classes = 10 - - @pytest.fixture(scope="class") - def datamodule(self, request: SubRequest) -> DummyDataModule: - dm = DummyDataModule( - num_channels=3, - num_classes=self.num_classes, - multilabel=True, - batch_size=2, - num_workers=0, - ) - dm.prepare_data() - dm.setup() - return dm - - @pytest.fixture(scope="class", params=zip(["bce", "bce"], ["random", "random"])) - def config( - self, datamodule: DummyDataModule, request: SubRequest - ) -> Dict[str, Any]: - task_args: Dict[str, Any] = {} - task_args["classification_model"] = "resnet18" - task_args["learning_rate"] = 3e-4 - task_args["learning_rate_schedule_patience"] = 6 - task_args["in_channels"] = datamodule.num_channels - loss, weights = request.param - task_args["loss"] = loss - task_args["num_classes"] = self.num_classes - task_args["weights"] = weights - return task_args + # Instantiate trainer + trainer = Trainer(fast_dev_run=True, log_every_n_steps=1) + trainer.fit(model=model, datamodule=datamodule) + trainer.test(model=model, datamodule=datamodule) @pytest.fixture - def task( - self, config: Dict[str, Any], monkeypatch: Generator[MonkeyPatch, None, None] - ) -> MultiLabelClassificationTask: - task = MultiLabelClassificationTask(**config) - monkeypatch.setattr(task, "log", mocked_log) # type: ignore[attr-defined] - return task - - def test_training( - self, datamodule: DummyDataModule, task: ClassificationTask - ) -> None: - batch = next(iter(datamodule.train_dataloader())) - task.training_step(batch, 0) - task.training_epoch_end(0) - - def test_validation( - self, datamodule: DummyDataModule, task: ClassificationTask - ) -> None: - batch = next(iter(datamodule.val_dataloader())) - task.validation_step(batch, 0) - task.validation_epoch_end(0) - - def test_test(self, datamodule: DummyDataModule, task: ClassificationTask) -> None: - batch = next(iter(datamodule.test_dataloader())) - task.test_step(batch, 0) - task.test_epoch_end(0) - - def test_invalid_loss(self, config: Dict[str, Any]) -> None: - config["loss"] = "invalid_loss" - error_message = "Loss type 'invalid_loss' is not valid." - with pytest.raises(ValueError, match=error_message): - MultiLabelClassificationTask(**config) + def model_kwargs(self) -> Dict[Any, Any]: + return { + "classification_model": "resnet18", + "in_channels": 1, + "loss": "ce", + "num_classes": 1, + "weights": "random", + } + + def test_invalid_loss(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["loss"] = "invalid_loss" + match = "Loss type 'invalid_loss' is not valid." + with pytest.raises(ValueError, match=match): + MultiLabelClassificationTask(**model_kwargs) diff --git a/tests/trainers/test_regression.py b/tests/trainers/test_regression.py index ed3af3a3b63..574c930e7d6 100644 --- a/tests/trainers/test_regression.py +++ b/tests/trainers/test_regression.py @@ -2,73 +2,40 @@ # Licensed under the MIT License. import os -from typing import Any, Dict, Generator, cast +from typing import Any, Dict, Type, cast import pytest -from _pytest.monkeypatch import MonkeyPatch from omegaconf import OmegaConf +from pytorch_lightning import LightningDataModule, Trainer -from torchgeo.datamodules import CycloneDataModule +from torchgeo.datamodules import COWCCountingDataModule, CycloneDataModule from torchgeo.trainers import RegressionTask -from .test_utils import mocked_log - class TestRegressionTask: - @pytest.fixture(scope="class") - def datamodule(self) -> CycloneDataModule: - root = os.path.join("tests", "data", "cyclone") - seed = 0 - batch_size = 1 - num_workers = 0 - dm = CycloneDataModule(root, seed, batch_size, num_workers) - dm.prepare_data() - dm.setup() - return dm - - @pytest.fixture - def config(self) -> Dict[str, Any]: - task_conf = OmegaConf.load( - os.path.join("conf", "task_defaults", "cyclone.yaml") - ) - task_args = OmegaConf.to_object(task_conf.experiment.module) - task_args = cast(Dict[str, Any], task_args) - return task_args - - @pytest.fixture - def task( - self, config: Dict[str, Any], monkeypatch: Generator[MonkeyPatch, None, None] - ) -> RegressionTask: - task = RegressionTask(**config) - monkeypatch.setattr(task, "log", mocked_log) # type: ignore[attr-defined] - return task - - def test_configure_optimizers(self, task: RegressionTask) -> None: - out = task.configure_optimizers() - assert "optimizer" in out - assert "lr_scheduler" in out - - def test_training( - self, datamodule: CycloneDataModule, task: RegressionTask - ) -> None: - batch = next(iter(datamodule.train_dataloader())) - task.training_step(batch, 0) - task.training_epoch_end(0) - - def test_validation( - self, datamodule: CycloneDataModule, task: RegressionTask - ) -> None: - batch = next(iter(datamodule.val_dataloader())) - task.validation_step(batch, 0) - task.validation_epoch_end(0) - - def test_test(self, datamodule: CycloneDataModule, task: RegressionTask) -> None: - batch = next(iter(datamodule.test_dataloader())) - task.test_step(batch, 0) - task.test_epoch_end(0) - - def test_invalid_model(self, config: Dict[str, Any]) -> None: - config["model"] = "invalid_model" - error_message = "Model type 'invalid_model' is not valid." - with pytest.raises(ValueError, match=error_message): - RegressionTask(**config) + @pytest.mark.parametrize( + "name,classname", + [("cowc_counting", COWCCountingDataModule), ("cyclone", CycloneDataModule)], + ) + def test_trainer(self, name: str, classname: Type[LightningDataModule]) -> None: + conf = OmegaConf.load(os.path.join("conf", "task_defaults", name + ".yaml")) + conf_dict = OmegaConf.to_object(conf.experiment) + conf_dict = cast(Dict[Any, Dict[Any, Any]], conf_dict) + + # Instantiate datamodule + datamodule_kwargs = conf_dict["datamodule"] + datamodule = classname(**datamodule_kwargs) + + # Instantiate model + model_kwargs = conf_dict["module"] + model = RegressionTask(**model_kwargs) + + # Instantiate trainer + trainer = Trainer(fast_dev_run=True, log_every_n_steps=1) + trainer.fit(model=model, datamodule=datamodule) + trainer.test(model=model, datamodule=datamodule) + + def test_invalid_model(self) -> None: + match = "Model type 'invalid_model' is not valid." + with pytest.raises(ValueError, match=match): + RegressionTask(model="invalid_model") diff --git a/tests/trainers/test_segmentation.py b/tests/trainers/test_segmentation.py index 658e4870f57..1d13299334e 100644 --- a/tests/trainers/test_segmentation.py +++ b/tests/trainers/test_segmentation.py @@ -2,95 +2,77 @@ # Licensed under the MIT License. import os -from typing import Any, Dict, Generator, cast +from typing import Any, Dict, Type, cast import pytest -from _pytest.fixtures import SubRequest -from _pytest.monkeypatch import MonkeyPatch from omegaconf import OmegaConf +from pytorch_lightning import LightningDataModule, Trainer -from torchgeo.datamodules import ChesapeakeCVPRDataModule +from torchgeo.datamodules import ( + ChesapeakeCVPRDataModule, + ETCI2021DataModule, + LandCoverAIDataModule, + NAIPChesapeakeDataModule, + OSCDDataModule, + SEN12MSDataModule, +) from torchgeo.trainers import SemanticSegmentationTask -from .test_utils import FakeTrainer, mocked_log - class TestSemanticSegmentationTask: - @pytest.fixture(scope="class") - def datamodule(self) -> ChesapeakeCVPRDataModule: - dm = ChesapeakeCVPRDataModule( - os.path.join("tests", "data", "chesapeake", "cvpr"), - ["de-test"], - ["de-test"], - ["de-test"], - patch_size=32, - patches_per_tile=2, - batch_size=2, - num_workers=0, - class_set=7, - ) - dm.prepare_data() - dm.setup() - return dm - - @pytest.fixture( - params=zip(["unet", "deeplabv3+", "fcn"], ["ce", "jaccard", "focal"]) + @pytest.mark.parametrize( + "name,classname", + [ + ("chesapeake_cvpr_5", ChesapeakeCVPRDataModule), + ("etci2021", ETCI2021DataModule), + ("landcoverai", LandCoverAIDataModule), + ("naipchesapeake", NAIPChesapeakeDataModule), + ("oscd_all", OSCDDataModule), + ("oscd_rgb", OSCDDataModule), + ("sen12ms_all", SEN12MSDataModule), + ("sen12ms_s1", SEN12MSDataModule), + ("sen12ms_s2_all", SEN12MSDataModule), + ("sen12ms_s2_reduced", SEN12MSDataModule), + ], ) - def config(self, request: SubRequest) -> Dict[str, Any]: - task_conf = OmegaConf.load( - os.path.join("conf", "task_defaults", "chesapeake_cvpr.yaml") - ) - task_args = OmegaConf.to_object(task_conf.experiment.module) - task_args = cast(Dict[str, Any], task_args) - segmentation_model, loss = request.param - task_args["segmentation_model"] = segmentation_model - task_args["loss"] = loss - return task_args + def test_trainer(self, name: str, classname: Type[LightningDataModule]) -> None: + conf = OmegaConf.load(os.path.join("conf", "task_defaults", name + ".yaml")) + conf_dict = OmegaConf.to_object(conf.experiment) + conf_dict = cast(Dict[Any, Dict[Any, Any]], conf_dict) - @pytest.fixture - def task( - self, config: Dict[str, Any], monkeypatch: Generator[MonkeyPatch, None, None] - ) -> SemanticSegmentationTask: - task = SemanticSegmentationTask(**config) - trainer = FakeTrainer() - monkeypatch.setattr(task, "trainer", trainer) # type: ignore[attr-defined] - monkeypatch.setattr(task, "log", mocked_log) # type: ignore[attr-defined] - return task + # Instantiate datamodule + datamodule_kwargs = conf_dict["datamodule"] + datamodule = classname(**datamodule_kwargs) - def test_configure_optimizers(self, task: SemanticSegmentationTask) -> None: - out = task.configure_optimizers() - assert "optimizer" in out - assert "lr_scheduler" in out + # Instantiate model + model_kwargs = conf_dict["module"] + model = SemanticSegmentationTask(**model_kwargs) - def test_training( - self, datamodule: ChesapeakeCVPRDataModule, task: SemanticSegmentationTask - ) -> None: - batch = next(iter(datamodule.train_dataloader())) - task.training_step(batch, 0) - task.training_epoch_end(0) + # Instantiate trainer + trainer = Trainer(fast_dev_run=True, log_every_n_steps=1) + trainer.fit(model=model, datamodule=datamodule) + trainer.test(model=model, datamodule=datamodule) - def test_validation( - self, datamodule: ChesapeakeCVPRDataModule, task: SemanticSegmentationTask - ) -> None: - batch = next(iter(datamodule.val_dataloader())) - task.validation_step(batch, 0) - task.validation_epoch_end(0) - - def test_test( - self, datamodule: ChesapeakeCVPRDataModule, task: SemanticSegmentationTask - ) -> None: - batch = next(iter(datamodule.test_dataloader())) - task.test_step(batch, 0) - task.test_epoch_end(0) + @pytest.fixture + def model_kwargs(self) -> Dict[Any, Any]: + return { + "segmentation_model": "unet", + "encoder_name": "resnet18", + "encoder_weights": None, + "in_channels": 1, + "num_classes": 1, + "loss": "ce", + "ignore_zeros": True, + } - def test_invalid_model(self, config: Dict[str, Any]) -> None: - config["segmentation_model"] = "invalid_model" - error_message = "Model type 'invalid_model' is not valid." - with pytest.raises(ValueError, match=error_message): - SemanticSegmentationTask(**config) + def test_invalid_model(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["segmentation_model"] = "invalid_model" + match = "Model type 'invalid_model' is not valid." + with pytest.raises(ValueError, match=match): + SemanticSegmentationTask(**model_kwargs) - def test_invalid_loss(self, config: Dict[str, Any]) -> None: - config["loss"] = "invalid_loss" - error_message = "Loss type 'invalid_loss' is not valid." - with pytest.raises(ValueError, match=error_message): - SemanticSegmentationTask(**config) + def test_invalid_loss(self, model_kwargs: Dict[Any, Any]) -> None: + model_kwargs["loss"] = "invalid_loss" + match = "Loss type 'invalid_loss' is not valid." + with pytest.raises(ValueError, match=match): + SemanticSegmentationTask(**model_kwargs) diff --git a/torchgeo/datamodules/chesapeake.py b/torchgeo/datamodules/chesapeake.py index 000ecd39ba8..2f575f048ba 100644 --- a/torchgeo/datamodules/chesapeake.py +++ b/torchgeo/datamodules/chesapeake.py @@ -185,6 +185,8 @@ def preprocess(self, sample: Dict[str, Any]) -> Dict[str, Any]: sample["image"] = sample["image"].float() + del sample["bbox"] + return sample def nodata_check( diff --git a/torchgeo/datamodules/landcoverai.py b/torchgeo/datamodules/landcoverai.py index 95256dffe5a..b0f23182a27 100644 --- a/torchgeo/datamodules/landcoverai.py +++ b/torchgeo/datamodules/landcoverai.py @@ -48,7 +48,7 @@ def preprocess(self, sample: Dict[str, Any]) -> Dict[str, Any]: sample["image"] = sample["image"] / 255.0 sample["image"] = sample["image"].float() - sample["mask"] = sample["mask"].float().unsqueeze(0) + 1 + sample["mask"] = sample["mask"].long() + 1 return sample diff --git a/torchgeo/datamodules/naip.py b/torchgeo/datamodules/naip.py index b00d142edee..928674dc5bd 100644 --- a/torchgeo/datamodules/naip.py +++ b/torchgeo/datamodules/naip.py @@ -63,6 +63,9 @@ def naip_transform(self, sample: Dict[str, Any]) -> Dict[str, Any]: """ sample["image"] = sample["image"] / 255.0 sample["image"] = sample["image"].float() + + del sample["bbox"] + return sample def chesapeake_transform(self, sample: Dict[str, Any]) -> Dict[str, Any]: @@ -75,6 +78,9 @@ def chesapeake_transform(self, sample: Dict[str, Any]) -> Dict[str, Any]: preprocessed Chesapeake data """ sample["mask"] = sample["mask"].long()[0] + + del sample["bbox"] + return sample def prepare_data(self) -> None: diff --git a/torchgeo/datasets/oscd.py b/torchgeo/datasets/oscd.py index 803d7405c09..555037d971f 100644 --- a/torchgeo/datasets/oscd.py +++ b/torchgeo/datasets/oscd.py @@ -60,8 +60,17 @@ class OSCD(VisionDataset): "https://partage.imt.fr/index.php/s/gpStKn4Mpgfnr63/download" ), } - - md5 = "7383412da7ece1dca1c12dc92ac77f09" + md5s = { + "Onera Satellite Change Detection dataset - Images.zip": ( + "c50d4a2941da64e03a47ac4dec63d915" + ), + "Onera Satellite Change Detection dataset - Train Labels.zip": ( + "4d2965af8170c705ebad3d6ee71b6990" + ), + "Onera Satellite Change Detection dataset - Test Labels.zip": ( + "8177d437793c522653c442aa4e66c617" + ), + } zipfile_glob = "*Onera*.zip" filename_glob = "*Onera*" @@ -254,7 +263,7 @@ def _download(self) -> None: self.urls[f_name], self.root, filename=f_name, - md5=self.md5 if self.checksum else None, + md5=self.md5s[f_name] if self.checksum else None, ) def _extract(self) -> None: diff --git a/torchgeo/trainers/byol.py b/torchgeo/trainers/byol.py index fb3565a7887..44e36a150b2 100644 --- a/torchgeo/trainers/byol.py +++ b/torchgeo/trainers/byol.py @@ -247,7 +247,7 @@ def __init__( model: Module, image_size: Tuple[int, int] = (256, 256), hidden_layer: Union[str, int] = -2, - input_channels: int = 4, + in_channels: int = 4, projection_size: int = 256, hidden_size: int = 4096, augment_fn: Optional[Module] = None, @@ -261,7 +261,7 @@ def __init__( image_size: the size of the training images hidden_layer: the hidden layer in ``model`` to attach the projection head to, can be the name of the layer or index of the layer - input_channels: number of input channels to the model + in_channels: number of input channels to the model projection_size: size of first layer of the projection MLP hidden_size: size of the hidden layer of the projection MLP augment_fn: an instance of a module that performs data augmentation @@ -277,7 +277,7 @@ def __init__( self.augment = augment_fn self.beta = beta - self.input_channels = input_channels + self.in_channels = in_channels self.encoder = EncoderWrapper( model, projection_size, hidden_size, layer=hidden_layer ) @@ -288,9 +288,7 @@ def __init__( # Perform a single forward pass to initialize the wrapper correctly self.encoder( - torch.zeros( # type: ignore[attr-defined] - 2, self.input_channels, *image_size - ) + torch.zeros(2, self.in_channels, *image_size) # type: ignore[attr-defined] ) def forward(self, x: Tensor) -> Tensor: @@ -315,21 +313,23 @@ class BYOLTask(LightningModule): def config_task(self) -> None: """Configures the task based on kwargs parameters passed to the constructor.""" - input_channels = self.hparams["input_channels"] + in_channels = self.hparams["in_channels"] pretrained = self.hparams["imagenet_pretraining"] encoder = None - if self.hparams["encoder"] == "resnet18": + if self.hparams["encoder_name"] == "resnet18": encoder = resnet18(pretrained=pretrained) - elif self.hparams["encoder"] == "resnet50": + elif self.hparams["encoder_name"] == "resnet50": encoder = resnet50(pretrained=pretrained) else: - raise ValueError(f"Encoder type '{self.hparams['encoder']}' is not valid.") + raise ValueError( + f"Encoder type '{self.hparams['encoder_name']}' is not valid." + ) layer = encoder.conv1 # Creating new Conv2d layer new_layer = Conv2d( - in_channels=input_channels, + in_channels=in_channels, out_channels=layer.out_channels, kernel_size=layer.kernel_size, stride=layer.stride, @@ -343,7 +343,7 @@ def config_task(self) -> None: ... # type: ignore[index] ] = Variable(layer.weight.clone(), requires_grad=True) # Copying the weights of the old layer to the extra channels - for i in range(input_channels - layer.in_channels): + for i in range(in_channels - layer.in_channels): channel = layer.in_channels + i new_layer.weight[:, channel : channel + 1, :, :].data[ ... # type: ignore[index] @@ -359,8 +359,8 @@ def __init__(self, **kwargs: Any) -> None: """Initialize a LightningModule for pre-training a model with BYOL. Keyword Args: - input_channels: number of channels on the input imagery - encoder: either "resnet18" or "resnet50" + in_channels: number of channels on the input imagery + encoder_name: either "resnet18" or "resnet50" imagenet_pretraining: bool indicating whether to use imagenet pretrained weights diff --git a/torchgeo/trainers/landcoverai.py b/torchgeo/trainers/landcoverai.py index 364aa19f4a3..7c9ac27856a 100644 --- a/torchgeo/trainers/landcoverai.py +++ b/torchgeo/trainers/landcoverai.py @@ -46,10 +46,10 @@ def training_step( # type: ignore[override] training loss """ x = batch["image"] - y = batch["mask"] + y = batch["mask"].float().unsqueeze(1) with torch.no_grad(): x, y = self.train_augmentations(x, y) - y = y.long().squeeze() + y = y.squeeze(1).long() y_hat = self.forward(x) y_hat_hard = y_hat.argmax(dim=1) @@ -76,7 +76,7 @@ def validation_step( # type: ignore[override] batch_idx: Index of current batch """ x = batch["image"] - y = batch["mask"].long().squeeze() + y = batch["mask"] y_hat = self.forward(x) y_hat_hard = y_hat.argmax(dim=1) @@ -120,7 +120,7 @@ def test_step( # type: ignore[override] batch_idx: Index of current batch """ x = batch["image"] - y = batch["mask"].long().squeeze() + y = batch["mask"] y_hat = self.forward(x) y_hat_hard = y_hat.argmax(dim=1) diff --git a/train.py b/train.py index ea80c556bd6..eac21a07d7f 100755 --- a/train.py +++ b/train.py @@ -43,19 +43,28 @@ TASK_TO_MODULES_MAPPING: Dict[ str, Tuple[Type[pl.LightningModule], Type[pl.LightningDataModule]] ] = { - "bigearthnet": (MultiLabelClassificationTask, BigEarthNetDataModule), + "bigearthnet_all": (MultiLabelClassificationTask, BigEarthNetDataModule), + "bigearthnet_s1": (MultiLabelClassificationTask, BigEarthNetDataModule), + "bigearthnet_s2": (MultiLabelClassificationTask, BigEarthNetDataModule), "byol": (BYOLTask, ChesapeakeCVPRDataModule), - "chesapeake_cvpr": (ChesapeakeCVPRSegmentationTask, ChesapeakeCVPRDataModule), + "chesapeake_cvpr_5": (ChesapeakeCVPRSegmentationTask, ChesapeakeCVPRDataModule), + "chesapeake_cvpr_7": (ChesapeakeCVPRSegmentationTask, ChesapeakeCVPRDataModule), + "chesapeake_cvpr_prior": (ChesapeakeCVPRSegmentationTask, ChesapeakeCVPRDataModule), "cowc_counting": (RegressionTask, COWCCountingDataModule), "cyclone": (RegressionTask, CycloneDataModule), "eurosat": (ClassificationTask, EuroSATDataModule), "etci2021": (SemanticSegmentationTask, ETCI2021DataModule), "landcoverai": (LandCoverAISegmentationTask, LandCoverAIDataModule), "naipchesapeake": (NAIPChesapeakeSegmentationTask, NAIPChesapeakeDataModule), - "oscd": (SemanticSegmentationTask, OSCDDataModule), + "oscd_all": (SemanticSegmentationTask, OSCDDataModule), + "oscd_rgb": (SemanticSegmentationTask, OSCDDataModule), "resisc45": (RESISC45ClassificationTask, RESISC45DataModule), - "sen12ms": (SemanticSegmentationTask, SEN12MSDataModule), - "so2sat": (ClassificationTask, So2SatDataModule), + "sen12ms_all": (SemanticSegmentationTask, SEN12MSDataModule), + "sen12ms_s1": (SemanticSegmentationTask, SEN12MSDataModule), + "sen12ms_s2_all": (SemanticSegmentationTask, SEN12MSDataModule), + "sen12ms_s2_reduced": (SemanticSegmentationTask, SEN12MSDataModule), + "so2sat_supervised": (ClassificationTask, So2SatDataModule), + "so2sat_unsupervised": (ClassificationTask, So2SatDataModule), "ucmerced": (ClassificationTask, UCMercedDataModule), }