-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LEVIR-CD Dataset and Datamodule #1770
Changes from all commits
163317b
c0c8c0c
22055c3
3f34596
f4d5282
db9d560
a37776f
b10e073
4dcab67
76a392c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,6 +267,12 @@ LandCover.ai | |
|
||
.. autoclass:: LandCoverAI | ||
|
||
LEVIR-CD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
^^^^^^^^ | ||
|
||
.. autoclass:: LEVIRCDBase | ||
.. autoclass:: LEVIRCD | ||
|
||
LEVIR-CD+ | ||
^^^^^^^^^ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ Dataset,Task,Source,License,# Samples,# Classes,Size (px),Resolution (m),Bands | |
`IDTReeS`_,"OD,C",Aerial,"CC-BY-4.0",591,33,200x200,0.1--1,RGB | ||
`Inria Aerial Image Labeling`_,S,Aerial,-,360,2,"5,000x5,000",0.3,RGB | ||
`LandCover.ai`_,S,Aerial,"CC-BY-NC-SA-4.0","10,674",5,512x512,0.25--0.5,RGB | ||
`LEVIR-CD`_,CD,Google Earth,-,637,2,"1,024x1,024",0.5,RGB | ||
`LEVIR-CD+`_,CD,Google Earth,-,985,2,"1,024x1,024",0.5,RGB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could prob just combine |
||
`LoveDA`_,S,Google Earth,"CC-BY-NC-SA-4.0","5,987",7,"1,024x1,024",0.3,RGB | ||
`MapInWild`_,S,"Sentinel-1/2, ESA WorldCover, NOAA VIIRS DNB","CC-BY-4.0",1018,1,1920x1920,10--463.83,"SAR, MSI, 2020_Map, avg_rad" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import hashlib | ||
import os | ||
import shutil | ||
import zipfile | ||
|
||
import numpy as np | ||
from PIL import Image | ||
|
||
np.random.seed(0) | ||
|
||
|
||
def create_image(path: str) -> None: | ||
Z = np.random.randint(255, size=(1, 1, 3), dtype=np.uint8) | ||
img = Image.fromarray(Z).convert("RGB") | ||
img.save(path) | ||
|
||
|
||
def create_mask(path: str) -> None: | ||
Z = np.random.randint(2, size=(1, 1, 3), dtype=np.uint8) * 255 | ||
img = Image.fromarray(Z).convert("L") | ||
img.save(path) | ||
|
||
|
||
if __name__ == "__main__": | ||
splits = ["train", "val", "test"] | ||
filenames = ["train.zip", "val.zip", "test.zip"] | ||
directories = ["A", "B", "label"] | ||
|
||
for split, filename in zip(splits, filenames): | ||
for directory in directories: | ||
os.mkdir(directory) | ||
|
||
for i in range(2): | ||
path = os.path.join("A", f"{split}_{i}.png") | ||
create_image(path) | ||
|
||
path = os.path.join("B", f"{split}_{i}.png") | ||
create_image(path) | ||
|
||
path = os.path.join("label", f"{split}_{i}.png") | ||
create_mask(path) | ||
|
||
# compress data | ||
with zipfile.ZipFile(filename, mode="a") as f: | ||
for directory in directories: | ||
for file in os.listdir(directory): | ||
f.write(os.path.join(directory, file)) | ||
|
||
for directory in directories: | ||
shutil.rmtree(directory) | ||
|
||
# compute checksum | ||
with open(filename, "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"{filename}: {md5}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/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 | ||
|
||
np.random.seed(0) | ||
|
||
|
||
def create_image(path: str) -> None: | ||
isaaccorley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Z = np.random.randint(255, size=(1, 1, 3), dtype=np.uint8) | ||
img = Image.fromarray(Z).convert("RGB") | ||
img.save(path) | ||
|
||
|
||
def create_mask(path: str) -> None: | ||
Z = np.random.randint(2, size=(1, 1, 3), dtype=np.uint8) * 255 | ||
img = Image.fromarray(Z).convert("L") | ||
img.save(path) | ||
|
||
|
||
if __name__ == "__main__": | ||
root = "LEVIR-CD+" | ||
splits = ["train", "test"] | ||
directories = ["A", "B", "label"] | ||
|
||
if os.path.exists(root): | ||
shutil.rmtree(root) | ||
|
||
for split in splits: | ||
for directory in directories: | ||
os.makedirs(os.path.join(root, split, directory)) | ||
|
||
for i in range(2): | ||
folder = os.path.join(root, split, "A") | ||
path = os.path.join(folder, f"0{i}.png") | ||
create_image(path) | ||
|
||
folder = os.path.join(root, split, "B") | ||
path = os.path.join(folder, f"0{i}.png") | ||
create_image(path) | ||
|
||
folder = os.path.join(root, split, "label") | ||
path = os.path.join(folder, f"0{i}.png") | ||
create_mask(path) | ||
|
||
# Compress data | ||
shutil.make_archive(root, "zip", ".", root) | ||
|
||
# compute checksum | ||
with open(f"{root}.zip", "rb") as f: | ||
md5 = hashlib.md5(f.read()).hexdigest() | ||
print(f"{root}.zip: {md5}") | ||
|
||
shutil.rmtree(root) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file will eventually be removed once we have a trainer for CD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prob just have a single header with 2 versions