|
import collections |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
_DESCRIPTION='SkyScenes, a synthetic dataset of densely annotated aerial images captured from Unmanned Aerial Vehicle (UAV) perspectives. SkyScenes is curated from CARLA to comprehensively capture diversity across layout (urban and rural maps), weather conditions, times of day, pitch angles and altitudes with corresponding semantic, instance and depth annotations.' |
|
_HOMEPAGE = "skyscenes.github.io" |
|
_LICENSE = "MIT" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_CATEGORIES = ["unlabeled", "building", "fence", "other", "pedestrian", "pole", |
|
"roadline", "road", "sidewalk", "vegetation", "vehicles", "wall", |
|
"trafficsign", "sky", "ground", "bridge", "railtrack", "guardrail", |
|
"trafficlight", "static", "dynamic", "water", "terrain"] |
|
|
|
|
|
class SKYSCENESConfig(datasets.BuilderConfig): |
|
"""Builder Config for SkyScenes""" |
|
|
|
def __init__(self, data_urls, metadata_url, **kwargs): |
|
""" |
|
BuilderConfig for SkyScenes. |
|
Args: |
|
data_urls: `dict`, name to url to download the zip file from. |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
super(SKYSCENESConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs) |
|
self.data_urls = data_urls |
|
self.metadata_url = metadata_url |
|
|
|
|
|
class SKYSCENES(datasets.GeneratorBasedBuilder): |
|
"""satellite-building-segmentation instance segmentation dataset""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
BUILDER_CONFIGS = [ |
|
SKYSCENESConfig( |
|
name="full", |
|
description="Full version of skyscenes dataset.", |
|
data_urls="https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/trial_Segment/H_35_P_90/ClearNoon/Town03/Town03.tar.gz", |
|
metadata_url = "https://huggingface.co/datasets/hoffman-lab/SkyScenes/resolve/main/Images/Town01.txt",) |
|
|
|
|
|
|
|
|
|
|
|
] |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"image": datasets.Image(), |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
data_files = dl_manager.download_and_extract(self.config.data_urls) |
|
split_metadata_paths = dl_manager.download(self.config.metadata_url) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"images": data_files, |
|
"metadata_path": split_metadata_paths, |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, images, metadata_path): |
|
"""Generate images and labels for splits.""" |
|
|
|
|
|
|
|
|
|
for filename in os.listdir(images): |
|
filepath = os.path.join(images, filename) |
|
with open(filepath, "rb") as f: |
|
image_bytes = f.read() |
|
|
|
|
|
|
|
|
|
yield filepath, { |
|
"image": {"path": filepath, "bytes": image_bytes}, |
|
} |